Skip to content

Commit

Permalink
使用reverse的方式获取编辑地址
Browse files Browse the repository at this point in the history
  • Loading branch information
the5fire committed Jun 1, 2014
1 parent 3868a6c commit 7615aea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions selfblog/blog/adminx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#coding:utf-8
import xadmin
from django.core import urlresolvers

from .models import Post
from .models import Category
Expand All @@ -20,10 +21,11 @@ class PostAdmin(object):
save_on_top = True

def preview(self, obj):
url_edit = urlresolvers.reverse('xadmin:blog_post_change', args=(obj.id,))
return u'''
<span><a href="/%s.html" target="_blank">预览</a></span>
<span><a href="/xadmin/blog/post/%s/update/" target="_blank">编辑</a></span>
''' % (obj.alias, obj.id)
<span><a href="/%s.html" target="_blank">预览</a></span>
<span><a href="%s" target="_blank">编辑</a></span>
''' % (obj.alias, url_edit)

preview.short_description = u'操作'
preview.allow_tags = True
Expand Down

0 comments on commit 7615aea

Please sign in to comment.