I have django app, and have one problem: Category and page application have the same url:
Here is category.urls.py:
urlpatterns += patterns('',
url('(?P<slug>[0-9A-Za-z-_.]+)/$', Category.as_view(), name='category')
)
And here is page.urls.py:
urlpatterns += patterns('',
url(r'^(?P<slug>[0-9A-Za-z-_.]+)$', Page.as_view(), name='page')
)
So here is a problem - you can't open page with such urls, so i need this solution:
If here is exists Category with slug from url - open Category view, if there is no Category with such url, go to Page view.
But i don't know how to do this with RIGHT on django, without creating additional function like this:
def freeurl(request, slug):
try:
Category.objects.get(slug=slug)
go to Category view
except Category.DoesNotExists:
go to Page view
is it possible ?