From 702cd2099186cafcf0f1a4ffcda099cef3c9e178 Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Wed, 30 Apr 2014 20:08:39 +0800 Subject: fixed problem with 'transcript_url' field of UserProfileAdmin --- account/admin.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/account/admin.py b/account/admin.py index f491104..fe6fca1 100644 --- a/account/admin.py +++ b/account/admin.py @@ -113,10 +113,15 @@ class UserProfileAdmin(admin.ModelAdmin): """ return the html code of transcript with url link """ - return format_html('%(name)s' % { - 'url': obj.transcript.url, - 'name': os.path.basename(obj.transcript.name), - }) + transcript = obj.transcript + if transcript: + html = '%(name)s' % { + 'url': transcript.url, + 'name': os.path.basename(transcript.name), + } + else: + html = _("Null") + return format_html(html) transcript_url.short_description = _("Transcript") def attachments(self, obj): -- cgit v1.2.2