Alessandro Ronchi schrieb: > I want to make a regxep in my urls.py that takes the name of the view from > the url. > Something like: > > > (r'^views/(?P<name>\w+)/', 'myproject.database.reports.' + name), > > is it possible? I've a lot of views with the same rule and I want to make > them be available without duplicate names 3 or 4 times.
That's possible, but you need a wrapper: (r'^views/(?P<name>\w+)/', 'myproject.views.wrapper'), # views.py (untested) def wrapper(request, name): module=__import__("myproject.database.reports.%s" % name, globals(), locals(), [name]) method=getattr(module, name) return method(request) -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---