Open ceoro9 opened 5 years ago
# models.py
from django.db import models
from django.utils.translation import gettext_lazy as _
YES = "y"
NO = "n"
NOT_FOUND = None
YES_NO_CHOICES = (
(YES, _("yes")),
(NO, _("no")),
(NOT_FOUND, _("not completed")),
)
class YourModel(models.Model):
called_y_n = models.CharField(
_("Called (Y/N)"),
choices=YES_NO_CHOICES,
max_length=10,
null=True,
blank=True,
default=None,
db_index=True,
)
# admin.py
from django.contrib import admin
from .models import YourModel
class YourModelAdmin(admin.ModelAdmin):
list_filter = ("called_y_n",)
admin.site.register(YourModel, YourModelAdmin)
When you specify choices with
None
option on model field and in admin model set that field in filters, something really strange happens when you chooseNone
option in pop up list, I mean everything works okay on backend, but here is the problem with styles.When you choose not completed (None) option.