Overriding admin view methods - Django
I nee开发者_如何学运维d to override the an add form within the admin panel.
I'm thinking of accomplishing this by writing a view which would then point to the admin view for the final result.
Something similar to this (where admin_basic_ass_user_view is the admin view)
@required_login
def add_user(request):
if condition:
return admin_basic_add_user_view(request)
return render_to_response("admin/auth/user/add_form.html", { ... })
Any ideas?
Why not just override the relevant methods with your ModelAdmin subclass? That's why it's a class, after all.
Add something like this to your urls.py
((r'^admin/auth/users/add/$', 'Project.SomeAPP.admin_views.add_user'),
The path needs to point to your new view. You should see the results of your new view in the admin interface's add user page.
EDIT: I forgot to mention, make sure you add that line BEFORE the normal admin interface line in the urls.py
精彩评论