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!!

Answers


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


Need Your Help

Is it possible to have a Master ViewPage bound to a different object than the child viewpage?

c# asp.net asp.net-mvc-2

I wanted to do this because i wanted to have a master page bound to a strongly typed model, so that it can contain all of the Model Data that i will need for each page. But then I also need each

Circular Path algorithm

algorithm order path-finding circular-dependency

I am stuck at developing a circular path algorithm creating a path out of points.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.