In Django 1.8.6, by default, whenever I provide a list_display
option to a ModelAdmin subclass, the first field in the list becomes clickable and leads to the object edit page.
Is there a way to keep the order of the fields in list_display
, but change the clickable one?
Currently, I have the id
field clickable (it goes first in list_display
), which is a tad small. I would like to better click on, say, name
to go to the edit page.
To use editable in a field you must specify either of following settings: null=True and blank=True, so that your field doesn't give required error during model save.
The Django admin is a powerful built-in tool giving you the ability to create, update, and delete objects in your database using a web interface. You can customize the Django admin to do almost anything you want.
To change the admin site header text, login page, and the HTML title tag of our bookstore's instead, add the following code in urls.py . The site_header changes the Django administration text which appears on the login page and the admin site. The site_title changes the text added to the <title> of every admin page.
The simplest way is by using the field option blank=True (docs.djangoproject.com/en/dev/ref/models/fields/#blank).
You could have a look at django.contrib.admin.ModelAdmin.list_display_links
Basically it is used like
class PersonAdmin(admin.ModelAdmin): list_display = ('first_name', 'last_name', 'birthday') list_display_links = ('first_name', 'last_name')
Hope this will help :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With