I have two different types of objects that I would like to live on the same URL. One group of objects should be passed to the "foo" view function, and another group should be passed to "bar".
I am currently doing this with a large long list of hard-tuned URLs like ...
urlpatterns = patterns('project.views',
(r'^a/$', 'foo'),
(r'^b/$', 'foo'),
(r'^c/$', 'foo'),
(r'^x/$', 'bar'),
(r'^y/$', 'bar'),
(r'^z/$', 'bar'),
)
Is it possible to define a list of each type of URL, for example ...
foo_urls = ['a', 'b', 'c'] #...
bar_urls = ['x', 'y', 'z'] #...
... and then check the incoming URL for these lists? (If it is in 'foo_urls', send 'project.views.foo', if it is in 'bar_urls', send to 'project.views.bar')?
I will limit myself to this structure supporting compatibility with URLs from the previous site, but any tips on ways to simplify my urls.py would be appreciated.