diff options
author | Weitian LI <liweitianux@gmail.com> | 2014-04-30 20:08:39 +0800 |
---|---|---|
committer | Weitian LI <liweitianux@gmail.com> | 2014-04-30 20:08:39 +0800 |
commit | 702cd2099186cafcf0f1a4ffcda099cef3c9e178 (patch) | |
tree | 566ea64cfbcaea83a71c0e9d347f7e2d31d43da7 | |
parent | f36c475dd6ddf030743f73b0c563ad0165b00310 (diff) | |
download | django-skaschool-702cd2099186cafcf0f1a4ffcda099cef3c9e178.tar.bz2 |
fixed problem with 'transcript_url' field of UserProfileAdmin
-rw-r--r-- | account/admin.py | 13 |
1 files 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('<a href="%(url)s">%(name)s</a>' % { - 'url': obj.transcript.url, - 'name': os.path.basename(obj.transcript.name), - }) + transcript = obj.transcript + if transcript: + html = '<a href="%(url)s">%(name)s</a>' % { + '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): |