From c64f7f065a13876901fffa6249667e865d33fd9a Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 17 Apr 2007 07:08:42 +0000 Subject: [PATCH] Fixed #4060 -- Databrowse no longer requires admin site to be installed git-svn-id: http://code.djangoproject.com/svn/django/trunk@5016 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/databrowse/datastructures.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django/contrib/databrowse/datastructures.py b/django/contrib/databrowse/datastructures.py index 346a1e95e0..24f2e68f46 100644 --- a/django/contrib/databrowse/datastructures.py +++ b/django/contrib/databrowse/datastructures.py @@ -8,6 +8,8 @@ from django.utils import dateformat from django.utils.text import capfirst from django.utils.translation import get_date_formats +EMPTY_VALUE = '(None)' + class EasyModel(object): def __init__(self, site, model): self.site = site @@ -134,14 +136,13 @@ class EasyInstanceField(object): # This import is deliberately inside the function because it causes # some settings to be imported, and we don't want to do that at the # module level. - from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE if self.field.rel: if isinstance(self.field.rel, models.ManyToOneRel): objs = getattr(self.instance.instance, self.field.name) elif isinstance(self.field.rel, models.ManyToManyRel): # ManyToManyRel return list(getattr(self.instance.instance, self.field.name).all()) elif self.field.choices: - objs = dict(self.field.choices).get(self.raw_value, EMPTY_CHANGELIST_VALUE) + objs = dict(self.field.choices).get(self.raw_value, EMPTY_VALUE) elif isinstance(self.field, models.DateField) or isinstance(self.field, models.TimeField): if self.raw_value: date_format, datetime_format, time_format = get_date_formats() @@ -152,7 +153,7 @@ class EasyInstanceField(object): else: objs = capfirst(dateformat.format(self.raw_value, date_format)) else: - objs = EMPTY_CHANGELIST_VALUE + objs = EMPTY_VALUE elif isinstance(self.field, models.BooleanField) or isinstance(self.field, models.NullBooleanField): objs = {True: 'Yes', False: 'No', None: 'Unknown'}[self.raw_value] else: