From 775c06a959bfd1e156810b632604abf845f11be8 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 5 May 2006 02:59:58 +0000 Subject: [PATCH] Fixed #1729 -- Changed get_FIELD_filename() to return an empty string when field fiel's value is null. Thanks, rhettg@gmail.com git-svn-id: http://code.djangoproject.com/svn/django/trunk@2839 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 + django/db/models/base.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index e7b53d5bf0..4e44004768 100644 --- a/AUTHORS +++ b/AUTHORS @@ -97,6 +97,7 @@ answer newbie questions, and generally made Django that much better: Daniel Poelzleithner J. Rademaker Brian Ray + rhettg@gmail.com Oliver Rutherfurd Ivan Sagalaev (Maniac) David Schein diff --git a/django/db/models/base.py b/django/db/models/base.py index 2185471e2b..932b533291 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -281,7 +281,9 @@ class Model(object): return getattr(self, cachename) def _get_FIELD_filename(self, field): - return os.path.join(settings.MEDIA_ROOT, getattr(self, field.attname)) + if getattr(self, field.attname): # value is not blank + return os.path.join(settings.MEDIA_ROOT, getattr(self, field.attname)) + return '' def _get_FIELD_url(self, field): if getattr(self, field.attname): # value is not blank