def _link object anchor user_id None try from account models import Us

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def _link(object, anchor=u''):
user_id = None
try:
from account.models import UserProfile
if isinstance(object,User):
object = object.get_profile()
if isinstance(object,UserProfile):
if getattr(settings,'LOGIN_DEBUG',False):
user_id = object.user.id
except ImportError:
print 'Could not import account.models'
pass
url = object.get_absolute_url()
anchor = anchor or smart_unicode(object)
return {
'user_id': user_id,
'url': url,
'anchor': anchor}
link = register.inclusion_tag('site/link.html')(_link)
unescaped_link = register.inclusion_tag('site/unescaped_link.html')(_link)