本文整理汇总了Python中accounts.models.UserProfile.intro方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.intro方法的具体用法?Python UserProfile.intro怎么用?Python UserProfile.intro使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.intro方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import intro [as 别名]
def save(self,request):
if self.cleaned_data['city'] or self.cleaned_data['website'] or self.cleaned_data['intro'] or self.cleaned_data['qq'] or self.cleaned_data['msn'] or self.cleaned_data['avatar']:
current_user = request.user
try:
profile = current_user.get_profile()
except UserProfile.DoesNotExist:
profile = None
if not profile:
profile = UserProfile()
profile.user = current_user
profile.song_ord_filed = 'post_datetime'
profile.city = self.cleaned_data['city']
profile.website = self.cleaned_data['website']
profile.intro = self.cleaned_data['intro']
profile.qq = self.cleaned_data['qq']
profile.msn = self.cleaned_data['msn']
if 'avatar' in request.FILES:
#删除掉原头像
import os
if profile and profile.avatar and os.path.exists(profile.avatar.path):
os.remove(profile.avatar.path)
profile.avatar = self.cleaned_data['avatar']#request.FILES["avatar"]
profile.save()
if self.cleaned_data['username'] != current_user.username:
current_user.username = self.cleaned_data['username']
current_user.save()