I'm with Tom here, this just feels wrong. The whole point of urls.py is
to have a clean mapping of URLs to views.

Of course I understand your problem, so let's look at the details.

> /<country>/  # front page for country
> /<country>/ <industry>/ # list of schools and companies with activities
> in that industry, in that country
> /<country>/<company>/ # list of industries company has activities in, in
> that country

This breaks if an industry with the same pk/slug as a company exists
(/de/foo/ as industry and /de/foo/ as company). You would never be able
to call the company again, as the industry just overlaps. This schema
just is badly designed and not able to handle this case in a sane way.
This is true for router-views, throwing UrlNotMatched or any other way.
You basicaly loose the clean mapping of your URLs. It could even happen,
that you overlap a valid company url by adding a new industry to your
database, moving that URL to a completely new content.

(Sidenote: I think this is a problem even the Django admin has. Just add
an Model with an CharField as primary key and insert "add" into this
field. You will neven be able too edit this in the admin, as the
add_view will be called instead.)

You could of course make sure the URLs never overlap by making the slug
unique. One easy way would be to add a prefix, but then again you could
implement this in your urls.py without any hassle
("/<country>/industry-<industry>/").

Another solution might be to add a router-view, which is based on
aliases. So you could have a central db-table which stores alias to view
releations (meaning: /de/foo/ -> (industry_view, slug=foo), /de/foo-2/
-> (company_view, slug=foo), stored inside the database). This way you
could avoid overlaying and even create fallback-names for duplicate
slugs. But you need a central storage to accomplish that. (Drupal works
this way.)

Anyway, I don't think throwing UrlNotMatched is the right solution here.

David

-- 
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.


Reply via email to