django无效语法(url。py第7行

时间:2021-06-04 04:36:54

this is the mysite/urls.py from a tutorial in making a website with python and django mysiteurls.py

这是mysite / url。py来自于用python和django mysiteurls.py创建网站的教程

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover() 
urlpatterns = patterns('',
   url(r'^admin/', include(admin.site.urls)),
   url(r'^blog/', include('blog.urls')),
)

When I try to hit my url I get invalid syntax. What's it not liking?

当我尝试点击我的url时,我得到了无效的语法。什么不喜欢?

Essentially I want the view to populate a template XML file I built. please help am creating a website and came across this error in my urls here is my code

本质上,我希望视图填充我构建的模板XML文件。请帮忙创建一个网站,并遇到这个错误在我的url这里是我的代码

blog/urls.py

from django.conf.urls import patterns,url
from django.views.generic import ListView
from blog.models import Post

i get an invalid syntax error on my code when i call it on my localbrowser

当我在本地浏览器上调用代码时,会得到一个无效的语法错误

urlpatterns = patterns('',
url(r'^',ListView.as_view(
  queryset=Post.objects.all()order_by("-date")[:10],
  template_name="blog.html")),
)

please help am new to the program

请帮助我了解这个项目

1 个解决方案

#1


4  

In the following line, the code is missing .:

在下面一行,代码缺失。

queryset=Post.objects.all().order_by("-date")[:10],
#                          ^

#1


4  

In the following line, the code is missing .:

在下面一行,代码缺失。

queryset=Post.objects.all().order_by("-date")[:10],
#                          ^