Sunday, February 27, 2011

urls.py usage

2. Studying example (CMS) in "Python Web Development with Django.
J.Forcier, P.Bissex, W.Chun" I have got an error:
https://docs.google.com/leaf?id=0B5W4njXO9ND_Mzg1M2U0ZGItYzZiMS00Y2Qx...

adding detailes. I study CMS project in Chapter 8 in that book.
Following authors I wrote:
1) project level cmsproject/urls.py:
from django.contrib import admin
from django.conf.urls.defaults import *
admin.autodiscover()
urlpatterns = patterns('',
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
# url(r'^admin/(.*)', admin.site.root),
url(r'^admin/(.*)', admin.site.urls),
url(r'^cms/', include('cmsproject.cms.urls')),
# Example:
# Uncomment the admin/doc line below to enable admin
documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)

2) application level cmsproject/cms/urls.py:
from django.conf.urls.defaults import *
from cms.models import Story
from cms.models import Category
info_dict = {'queryset': Story.objects.all(), 'template_object_name':
'story'}
urlpatterns = patterns('cmsproject.cms.views',
url(r'^category/(?P<slug>[-\w]+)/$', 'category', name="cms-
category"),
url(r'^search/$', 'search', name="cms-search"),
)
urlpatterns += patterns('django.views.generic.list_detail',
url(r'^(?P<slug>[-\w]+)/$', 'object_detail', info_dict, name="cms-
story"),
url(r'^$', 'object_list', info_dict, name="cms-home"),
)

error message is: TemplateSyntaxError at /admin/
Caught AlreadyRegistered while rendering: The model Category is
already registered

I also don't understand why cmsproject/cms/urls.py contains = but not
+= in the statement
urlpatterns = patterns...

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment