my url is url(r'^login/(?P<email>\w+@\w+\.\w+)$', 'login'), how can I get the url as /login
well, if my request path is 127.0.0.1:8000/admin/user/edit/10, then I want to check whether the current user A has the permission to access the /admin/user/edit, when I use url = request.path, I get the url as /admin/user/edit/10.
But I want to get url = '/admin/user/edit' instead url = '/admin/user/edit/10'.So how can I get the correct url??much appreciate!!
Why don't you use the permission_required decorator above your view?
@permission_required('app.edit_right') # Fill in your permission def edit_user(request): #do stuff here
If the user (or the groups he's in) doesn't have this permission, then he will be redirected. Look for more info on the Django docs