0

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

1
  • it worked but defined another error Indentation Error unexpected indent (urls.py, line 1) Commented Feb 4, 2014 at 11:22

1 Answer 1

4

In the following line, the code is missing .:

queryset=Post.objects.all().order_by("-date")[:10],
#                          ^
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.