django-admin

How to change the database name display in django admin site?

How to change the database name display in django admin site? Question: Is it possible to change change the database name in django admin site? Just like how I change the following: admin.site.site_header = "Administrator" admin.site.site_title = "Administrator" admin.site.index_title = "Admin" Asked By: Claire Ann Vargas || Source Answers: There are two options, you can …

Total answers: 1

admin.site.register doesn't add my app in admin Django

admin.site.register doesn't add my app in admin Django Question: I’m trying to see the models in the admin. I’ve tried everything but nothing seems to work, could you help me? Note: I’ve also tried with admin.autodiscover() but it didn’t work. Also, I have installed the apps correctly and made the migrations without problems. Here’s what …

Total answers: 2

Display the history of an object in two apps together in django admin

Display the history of an object in two apps together in django admin Question: I have two apps (profiling and ticketing) the ticketing app has three models in names of member,ticket,comment, and the profiling app has one model in name of profile. I do some changes on an profile object via profiling app it displays …

Total answers: 1

Django admin: Filter field by range

Django admin: Filter field by range Question: I have a model called Person. Person has fields like name/surname and age. Now what I want to achieve is to have a filter in django admin that can filter age in some custom ranges so 10-15. After reading some posts my best shoot is: class RangeFilter(SimpleListFilter): title …

Total answers: 3

Django admin – prevent changing a field after it has become true

Django admin – prevent changing a field after it has become true Question: I have a model registred in admin.py: class OrderAdmin(admin.ModelAdmin): list_display = (‘org_name’, ‘address’, ‘total_cost’, ‘phone’, ‘data_time’, ‘is_called’, ‘is_payed’) search_fields = (‘org_name’, ‘phone’) list_filter = (‘data_time’, ‘total_cost’, ‘data_time’) list_editable = (‘is_called’, ‘is_payed’) readonly_fields = (‘data_time’, ‘user’, ‘total_cost’) inlines = [OrderItemsAdmin, ] I need …

Total answers: 1

Make non-model field disabled or readonly in django admin based on condition

Make non-model field disabled or readonly in django admin based on condition Question: i have model, admin and form for it. But there is a field in my form that is not in the model and i’m doing some custom action with that field. I want this field to be readonly or hidden or disabled …

Total answers: 1

why can't hide slug field in django admin?

why can't hide slug field in django admin? Question: when i try to exclude ‘slug’ field in django admin form,i got this msg: "KeyError at /admin/post/post/add/ "Key ‘slug’ not found in ‘PostForm’. Choices are: author, content, image, title." why? django code: model: models.py : from django.db import models from django.utils import timezone from django.urls import …

Total answers: 3

Pass parameters in URL to Django Admin add_view

Pass parameters in URL to Django Admin add_view Question: I need to pass a parameter in the URL to the Django Admin add view, so that when I type the URL: http://localhost:8000/admin/myapp/car/add?brand_id=1, the add_view reads the brand_id parameter. I want to use this so that I can set a default value for the brand attribute …

Total answers: 4

disable dark mode in django admin

disable dark mode in django admin Question: The Problem I installed Django after couple of months. Current version is 3.2.4. Earlier Django-admin was just light-mode. Current Django-admin switches automatically to dark or light according to system theme. Well, I do not want this behaviour. I want Django-admin to be light theme irrespective of system theme. …

Total answers: 4

Add custom button near Save button Django-admin

Add custom button near Save button Django-admin Question: I have added a custom button in django admin, however its below the Save and Save and Close buttons, how can I make this custom button on the same line with the 2 buttons above, below is the image: Then, how I overridden the button with the …

Total answers: 3