我想在我已经包含在 settings.py 下面的视图中获取我的用户配置文件 ID
AUTH_PROFILE_MODULE = 'users.UserProfile'
查看代码:
def savecontent(request):
try:
logging.debug("=========================== in save content")
logging.debug(dir(request.user))
my_id = request.user.get_profile().id
logging.debug(my_id)
错误是:
2012-07-17 13:00:00,564 ERROR Error while saing content
Traceback (most recent call last):
File "/opt/labs/labs_site/content/views.py", line 21, in savecontent
my_id = request.user.get_profile().id
File "/opt/labs/django/django/utils/functional.py", line 185, in inner
return func(self._wrapped, *args)
AttributeError: 'AnonymousUser' object has no attribute 'get_profile'