开发者

Overriding admin view methods - Django

开发者 https://www.devze.com 2023-01-25 18:49 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消