Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically customize django admin columns?

Is it possible to let the users choose / change dynamically the columns displayed in a object list in Django administration ?

Things can surely be implemented "from scratch" by modifying the 'change_list.html' template but I was wondering if somebody has already had the same problem and/or if any django-pluggin can do that.

Thanks in advance,

like image 849
tomjerry Avatar asked Apr 08 '10 15:04

tomjerry


People also ask

Can we customize Django admin panel?

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.

How do I change the admin text in Django?

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.

Is Django's admin interface customizable if yes then how?

To implement it in your project, make a new app in your Django project named products. Install this application, type product in the INSTALLED_APPS list in settings.py file. We will now make models in the products app. The model will be used throughout the tutorial to customize the Django Admin.

Can we change Django admin theme?

To do so, you will have to change the project's settings.py . Find the TEMPLATES section and modify accordingly. To override the default template you first need to access the template you want to modify from the django/contrib/admin/templates/admin directory.


2 Answers

Since Django 1.4 you can do this using get_list_display(): https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_list_display

like image 112
Andy Baker Avatar answered Sep 25 '22 15:09

Andy Baker


django-xadmin has this feature:

django x-admin dynamic columns

It has some other cool features too, but I haven't started using it because the English translation of the documentation hasn't been released yet (as of Oct '13). You could look at the source code to give you some ideas.

Check out the live demo

User: admin Password: admin

Note: I have no involvement in x-admin, I just have the same question as the OP.

like image 25
CDMP Avatar answered Sep 23 '22 15:09

CDMP