Sunday, 15 May 2011

python - Access request object in admin.py outside the class -


How do I use the request object, so that I different Administrator idea based on user's rank

Below is the code ( admin.py ) I want to do this, but how to use the current user (Admin: Admin admin): list_desplay = ['post_title' , 'Body', 'rating'] class simplepost (admin.modeladmin): list_display = ['post_title', 'category'] if request.user.is_superuser: admin.site.register (post, advanced post) Other: admin.site .register (post, simple post)

thanks

Single class can write and For example:

  Class post admin (admin.modeladmin): df get_list_display (request): if request.user.is_superuser: [[post_title ',' body ',' Rating '] Return:  

Look for a list of the methods you can override.

['post_title', 'category']]

No comments:

Post a Comment