简体   繁体   中英

django invalid syntax(urls.py line 7

this is the mysite/urls.py from a tutorial in making a website with python and 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?

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

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

In the following line, the code is missing . :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM