On Tue, May 21, 2013 at 6:56 AM, Nikhil Verma <varma.nikhi...@gmail.com> wrote: > Hello Guys > > > I want to make the urls dynamic and change according to roles in the project > for every app. > Example if there is role x so it should change like x/manage/view_name() , > if the role is admin the urls will become /admin/manage/view_name(). > > So basically i want to know how can i access request variable from > middlewares into my main project urls. > I know how to access template context processors but want to learn how to > access request in urls. > > This is what i have written > > url_variable = 'corporate' > > for app_name in settings.INSTALLED_APPS: > if not app_name in excluded_apps: > app = get_app(app_name) > > > #----------------------------------------------------------------------- > # Per module url > > #----------------------------------------------------------------------- > for model in get_models(app): > model = model._meta.module_name[5:] > url_path = r"^manage/%s/?$" % (model.lower()) > view_name = "admin_manage_%s" % (model.lower()) > urlpatterns += patterns('project_name.%s.views' % app_name, > url(url_path, view_name, > name=view_name),)
I access the request in my middleware, e.g.: def process_request(self, request): if self.is_admin_url(request.path) and \ not self.is_admin_url(request.META['HTTP_REFERER']): request.session['last_site_url'] = request.META['HTTP_REFERER'] -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.