Url patterns catching unexpected patterns

Consider these patterns,:

url('edit/', edit_view, )
url('edit/bulk/', edit_bulk_view)

So when you try to go to ‘edit/bulk/’ you would get the edit_view, as ‘edit/’ pattern matched ‘edit/bulk/’.

Solution: Always use the smallest pattern which matches.:

url('^edit/$', edit_view, )
url('^edit/bulk/$', edit_bulk_view)

Tip: In most of the cases you should be starting you patterns with ^ and ending it with $.

Urlpatterns failing to catch expected patterns

You want to edit posts based on slugs, so you do:

url('^edit/(?P<entry_slug>\w-+)/$', edit_view, )

However this would not catch slugs with - in them.

Solution: Think of the each value the slug can take, if you allow charactors and dashes, the next line would catch all of them.

url(‘^edit/(?P<entry_slug>[w-]+)/$’, edit_view, )