In addition, you can use permissions to deny access for users to certain views by using the permission_required decorator, see:
http://docs.djangoproject.com/en/dev/topics/auth/ Wim On Nov 25, 4:46 pm, Knut Ivar Nesheim <knu...@gmail.com> wrote: > Hi Stefan, > > If you roll your own login view, this can be done by simply > redirecting to the correct url after authentication. You would have to > come up with the correct url by looking at the groups. Consider > something like this: > > def login_view(request): > # login and authenticate.. > user = User object > > url = get_redirect_url(user) > return HttpResponseRedirect(url) > > def get_redirect_url(user): > if user.groups.filter(name = 'Manager'): > return '/managers'/ > elif user.groups.filter(name = 'Users'): > return '/users/' > > return '/' > > This could be further improved by using some Django helpers, like > 'redirect' and 'reverse'. > > If you have many groups, you could improve this by having a dict > mapping group name to url. Consider something like this in your > settings > > LOGIN_URL_MAP = { > 'Managers': '/managers'/, > 'Users': '/users': > > } > > Then 'get_redirect_url' could look something like this: > > def get_redirect_url(user): > url = '/' > for group in user.groups.all(): > url = settings.LOGIN_URL_MAP[group.name] > > return url > > Regards > Knut > > On Thu, Nov 25, 2010 at 10:24 AM, stefanvonfintel > > > > > > > > <stefan.vonfin...@skyrove.com> wrote: > > Hi all. > > > I am new to Django and have just recently started using it for a new > > project at our company. > > I have a bit of problem at the moment. What I would ideally like is to > > have one central login for users and then redirect them based on the > > groups that > > they belong to once they have been authenticated successfully ie. for > > managers they get redirected towww.example.com/manager/and for > > normal > > users they get redirected towww.example.com/users/. > > > I have searched google and the forums for a while and can not get an > > answer to this question. > > So I have given up on that idea that's why at the moment I have got > > two different login forms one on /users/ and one on /managers/. But > > they are both using the login() and authenticate() functions that are > > built in to django. This is a problem since if you login to /users/ > > then you have access to /managers/ without logging in there. Or is the > > some other way that I am completely missing? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.