Thursday, March 12, 2015

Ch. 9 User Authentication

If you are tempted to change your urls.py to match the snippet provided in this chapter, don't do it!

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
    url(r'^about/$', views.about, name='about'),
    url(r'^category/(?P<category_name_slug>\w+)$', views.category, name='category'),
    url(r'^add_category/$', views.add_category, name='add_category'),
    url(r'^category/(?P<category_name_slug>\w+)/add_page/$', views.add_page, name='add_page'),
    url(r'^register/$', views.register, name='register'),
    url(r'^login/$', views.user_login, name='login'),
    )

I am struggling with regular expressions, but I kind of hacked my way through chapter 8 and got the forms to work. In this chapter, however, I noticed that

url(r'^category/(?P<category_name_slug>[\w\-]+)/$', views.category, name='category'),

changed to:

url(r'^category/(?P<category_name_slug>\w+)$', views.category, name='category')

do not change it! Leave it as url(r'^category/(?P<category_name_slug>[\w\-]+)/$', views.category, name='category') or your application will complain.

No comments:

Post a Comment