I have two different kinds of objects that I'd like to live under the same URL. One group of objects needs to be passed to the view function 'foo' and another group needs to be passed to 'bar'.
I'm currently doing this with a big long list of hardcoded URLs, like so...
urlpatterns = patterns('project.views',
(r'^a/$', 'foo'),
(r'^b/$', 'foo'),
(r'^c/$', 'foo'),
#...and so on until...
(r'^x/$', 'bar'),
(r'^y/$', 'bar'),
(r'^z/$', 'bar'),
)
Is it possible to define a list of each type of URLs like...
foo_urls = ['a', 'b', 'c'] #...
bar_urls = ['x', 'y', 'z'] #...
...and then check the incoming URL against those lists? (If it's in 'foo_urls', send to 'project.views.foo'; if it's in 'bar_urls', send to 'project.views.bar')?
I'm limited to keeping this structure to maintain compatibility with the URLs from the previous site, but any advice on ways to simplify my urls.py would be much appreciated.