Category "django-admin"

How to add a calculated field to a django admin inline

I am trying to add a calculated field to a Django Admin Inline. Consider this set of classes: models.py: class MyGroup(models.Model): group_name = models.Cha

Django Decimal field with value Decimal(0.00) is displayed as 0E-10 in the Django Admin Inline

Django 2.2. Model Definition. class BlockPeriod(BaseModel): price = models.DecimalField(max_digits=20, decimal_places=10) margin = models.DecimalField(m

Add a link to custom django admin view

I've created a custom admin view as documented here. class MyAdmin(admin.ModelAdmin): def get_urls(self): urls = super().get_urls() my_urls

How to enable django admin sidebar navigation in a custom view?

I have a view inheriting from LoginRequiredMixin, TemplateView, which renders some data using the admin/base_site.html template as the base. I treat it as a par

How to filter choices in Django2's autocomplete_fields?

In Django 2.0, autocomplete_fields was added, which is great. Without autocomplete_fields, I can change the queryset of a ForeignKeyField using formfield_for_f

Private Object Field in Django Admin

I'm wondering what the best way to have an editable field (by admins) for some object in Django admin that can't be viewable on the public site. For example, a

Why my Django admin is not loading with css?

I have developed a web app in Django and deployed it then I found out that admin page is not loading with CSS. I was gettting the admin page with css in local s

PermissionError: [Errno 13] Permission denied: '/manage.py'

I am trying to run the following command in docker-composer, to start project with django-admin: docker-compose run app sh -c "django-admin startproject app ."

Hide Django logo/name in header Django admin tool

I want to hide/change the name displayed in the header bar, the label that I want to change is "DJANGO" word as the next image shows"

What is the way to ignore/skip some issues from python bandit security issues report?

I've got a bunch of django_mark_safe errors >> Issue: [B703:django_mark_safe] Potential XSS on mark_safe function. Severity: Medium Confidence: High

Django admin display many-to-many field as links

Trying to get my Django admin to display a list of related objects as hyperlinks to those objects. These objects are related through a many-to-many relationship

Add field to AbstractUser admin page

I have an AbstractUser class in models.py file in order to extend the django user default class, class Profile(AbstractUser): address = models.CharField('A

How to wrap text in Django admin(set column width)

I have a model Item class Item(models.Model): id = models.IntegerField(primary_key=True) title = models.CharField(max_length=140, blank=True) descr

Add extra context to admin index page

In my admin.py of my admin dashboard app I added this following code: class MyAdminSite(admin.AdminSite): def index(self, request, extra_context=None):

Error while opening Django admin: "Error at /admin/ Incorrect padding"

I was making a web app using Django. I was using Django 3.0.7 for the sake. Then I upgraded to Django 3.1.1. When I reinstalled Django 3.0.7 I am unable to open

What's the difference between staff, admin, superuser in django?

Django has superuser, staff, admin… superuser and staff are in django.contib.auth.models.UserManager. Then there is the createsuperuser command of djan

Register custom user model with admin auth

In a Django project, I have a custom user model that adds one extra field: class User(AbstractUser): company = models.ForeignKey(Company, null=True, blank

Catch exception on save in Django admin?

I have a pre_save signal handler on a bunch of models, which write to a different database. If something goes wrong, I'd like to abort the whole save, or faili

Django-admin: show multi select field for JSONField

I have a model with a field channel (JSONField). I'm strong an array of string in db with channel. By default, a JSONField is shown as a textarea in django-admi

Override save method of Django Admin

Well, I want to save any instance of a model without taking care about DDBB structure. So I decide to override def save in every model´s class. Kind of: