TJB
TJB

Reputation: 3846

Suit form include on list display in admin

Im trying to use Django Suit's form includes to add a button to the list display of all my subscribers in the admin. In the documentation it says to add this to your admin.py file in the right app.

class SubscriberAdmin(admin.ModelAdmin):
    list_display = ('email', 'date')
    readonly_fields = ('email', 'date')

def has_add_permission(self, request):
    return False

suit_form_includes = (
    ('admin/suit_includes/suit_csv.html', 'top'),
)

However this only appears when clicking into an instance of an object, and doesn't show up on the admin page that shows the entire list of objects in the database. Is there a way to do this with Django Suit ? I had trouble finding anything on google.

suit form include template:

<a href="/schedule-demo/csv"><button class="btn btn-info">Export to File</button></a>

Admin instance display (Where its appearing):

enter image description here

Admin list display (Where I want it to appear):

enter image description here

Upvotes: 0

Views: 310

Answers (1)

Hurlu&#39;
Hurlu&#39;

Reputation: 340

What's doing django-suit, here, is that it is including your HTML snippet in the change_form that is displayed for your model, the change_form being where you can modify your model and save the changes into the database.

Where you want it to appear is the "change_list", aka the place where you can see all of your instances of that model in your database.

To add it your html snippet, you should extend your change_list.html with your own snippet : More info on expanding templates in the official documentation

Good luck !

Upvotes: 1

Related Questions