Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add some extra information to a django admin edit view?

I want to be able to include some information surrounding a users profile in the admin edit view. Is there a simple way of extending the edit view to include some arbitrary html?

like image 209
Kit Sunde Avatar asked Jan 27 '12 07:01

Kit Sunde


People also ask

How do I restrict access to parts of Django admin?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

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.

What we can do in admin portal in Django?

Overview. The Django admin application can use your models to automatically build a site area that you can use to create, view, update, and delete records. This can save you a lot of time during development, making it very easy to test your models and get a feel for whether you have the right data.


2 Answers

The easiest solution I found so far are readonly fields, see

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields

The most important in those is the fact that you can not only put fixed strings there (also HTML) but also functions which return anything

like image 120
ProfHase85 Avatar answered Oct 21 '22 05:10

ProfHase85


You can override admin templates.

like image 39
Thibault J Avatar answered Oct 21 '22 04:10

Thibault J