Something like this works. You will repeat something else, for example, model instances, as you mentioned, but the premise is the same:
for path in ["foo", "bar"]: urlpatterns += patterns("myapp.views", url(r"^%s/$" % path, "index", {}, name=path))
I posted this code in my urls.py This leads to a display of the following form:
http://127.0.0.1:8000/foo/ http://127.0.0.1:8000/bar/
Some notes:
- I'm not sure what your views are, so this just calls up a view called
index . - I name the URLs after their corresponding
path argument; You can choose them in different ways.
source share