Saturday, February 27, 2016

Re: errors while trying to add extra context (detailview, __getitem__)

> urlpatterns = patterns(['',
>     url(r'^$', TemplateView.as_view(template_name='library.html')),
>     url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),

You've got CodeDetail instead of CodeDetailView, is that correct? That's not the class that you posted earlier.


Additionally, "detail" URL's typically contain a PK or a slug match, because you need to know which object you want to find the details on. The last URL you have listed here is more akin to a typical ListView. 

Additionally to my addition, you are also lacking a $ at the end of the regex, which means that your other views that do contain the (?P<slug>) match will never hit, since 'code/' will match those URL's first before ever reaching your true detail view. Probably not what you want.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUgThvUA_oryfkFtccM_LfTVo445cmKRoJb0XeHGD8wtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment