The approach we take at work is to have a view that wraps around the product, category and occasion views and takes care of the fallthrough logic. I'm not a fan of this approach, because it means that you can't just look at the urlconf and see which pattern maps to which view function. On the other hand, I don't think your solution would solve this either, you'd end up having 3 patterns that could all match, making it non-obvious what the behaviour is.
Obviously the ideal solution is to scope URLs correctly to avoid all this in the first place, but I've found that in the real world this is easier said than done. So it would be nice to have an idiomatic solution. An alternative might be a kwarg on the url function, such as 'fallthrough_on_404'. But it all feels a bit hackish to me :/ Regards, Andy On 18 March 2013 15:23, julianb <julian....@gmail.com> wrote: > Hi, > > imagine the following use case: > > You build an online store where you have sorted products into several > categories and maybe associated an occasion. Now you want to build URLs. So > the URL schema that all of the store's owners agree on is: > > /<product-slug>/ > /<category-slug>/ > /<occasion-slug>/ > > Look simple. > > Because product slugs should generally be different to category slugs and > occasions, you expect no clashes here. And you don't want to bloat the URLs > by putting product/ and category/ in there. And you also do not want to > resort making it look cryptic by having just /p/<product-slug>/ and so on. > Then it comes to Django. How do you do that? > > Well, at the moment, as far as I am aware, you can't. The first URL will > match everything all the time, not giving the other views a chance to kick > in. > > So I propose some kind of URL fallthrough. The view could do > > raise UrlNotMatched > > and the dispatcher goes to the next possible matching view. > > Would that be good? Any thoughts? > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers?hl=en > . > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.