mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-22 14:21:50 +00:00
Fix Django 3.0 field choices diff
This commit is contained in:
parent
3acab4322b
commit
2010b49d06
2 changed files with 9 additions and 8 deletions
|
|
@ -8,7 +8,7 @@ from django.contrib.contenttypes.fields import GenericRelation
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import FieldDoesNotExist
|
||||
from django.db import models, DEFAULT_DB_ALIAS
|
||||
from django.db.models import QuerySet, Q
|
||||
from django.db.models import QuerySet, Q, Field
|
||||
from django.utils import formats, timezone
|
||||
from django.utils.encoding import smart_str
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
|
@ -258,9 +258,9 @@ class LogEntry(models.Model):
|
|||
values_display = []
|
||||
# handle choices fields and Postgres ArrayField to get human readable version
|
||||
choices_dict = None
|
||||
if hasattr(field, 'choices') and len(field.choices) > 0:
|
||||
if getattr(field, 'choices') and len(field.choices) > 0:
|
||||
choices_dict = dict(field.choices)
|
||||
if hasattr(field, 'base_field') and getattr(field.base_field, 'choices', False):
|
||||
if hasattr(field, 'base_field') and isinstance(field.base_field, Field) and getattr(field.base_field, 'choices') and len(field.base_field.choices) > 0:
|
||||
choices_dict = dict(field.base_field.choices)
|
||||
|
||||
if choices_dict:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Settings file for the Auditlog test suite.
|
||||
"""
|
||||
import os
|
||||
|
||||
SECRET_KEY = 'test'
|
||||
|
||||
|
|
@ -25,11 +26,11 @@ MIDDLEWARE = (
|
|||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'auditlog_tests_db',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': '',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '5432',
|
||||
'NAME': os.getenv('TEST_DB_NAME', 'auditlog_tests_db'),
|
||||
'USER': os.getenv('TEST_DB_USER', 'postgres'),
|
||||
'PASSWORD': os.getenv('TEST_DB_PASS', ''),
|
||||
'HOST': os.getenv('TEST_DB_HOST', '127.0.0.1'),
|
||||
'PORT': os.getenv('TEST_DB_PORT', '5432'),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue