Nick T
Nick T

Reputation: 26727

How do I link to a model's listing in the Django admin interface?

Linking to a model instance is fairly easy in Django: reverse('admin:myapp_mymodel_change, args=(myinstance.pk,)), but how do I link to the list (not the changelist) of objects that are of the MyApp.MyModel type?

My dirty hack works, but is a bit nasty:

admin_model_list = reverse('admin:myapp_mymodel_add')[:-5]

Upvotes: 0

Views: 59

Answers (1)

That is the changelist.

reverse('admin:myapp_mymodel_changelist') == reverse('admin:myapp_mymodel_add')[:-4]

Upvotes: 1

Related Questions