python - Django Generic Views Date-Based URLconf -
trying teach myself django running snag. generic views seem great idea find documentation little cryptic @ times (maybe i'm being prissy). have been trying use date based generics views in , archieveindexview.
i have attempted following non-djangoproject.com examples , still have problems. used example provided @ this site.
here current project/urls.py.
@ point, not worrying pattern matching, trying work.
from django.conf.urls import patterns, include, url django.views.generic.dates import archiveindexview blog.models import entry django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', archiveindexview.as_view('date_field': 'pub_date', 'queryset': entry.objects.all())), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), ) with setup keep receiving invalid syntax error @ line describing archiveindexview class. if comment out line problem goes away. if decouple urls appropriate app same error.
the error suggest have out of place, comma or have yet conclude is.
thank you!
use below code
from django.conf.urls import patterns, include, url django.views.generic.dates import archiveindexview blog.models import entry django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', archiveindexview.as_view({'date_field': 'pub_date', 'queryset': entry.objects.all()})), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), ) you seem forget {} brace required dict in url(r'^$', archiveindexview.as_view('date_field': 'pub_date', 'queryset': entry.objects.all())), line.
Comments
Post a Comment