RadiantHex
RadiantHex

Reputation: 25597

Overriding admin view methods - Django

I need 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?

Upvotes: 2

Views: 2669

Answers (2)

CoreyD
CoreyD

Reputation: 220

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

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 600059

Why not just override the relevant methods with your ModelAdmin subclass? That's why it's a class, after all.

Upvotes: 3

Related Questions