本文整理汇总了Python中profiles.models.Profile.name方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.name方法的具体用法?Python Profile.name怎么用?Python Profile.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profiles.models.Profile
的用法示例。
在下文中一共展示了Profile.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_profile
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import name [as 别名]
def save_profile(request):
profile = Profile()
profile.name = request.POST["tmp_name"]
profile.desc = request.POST["tmp_desc"]
profile.addr = request.POST["tmp_addr"]
profile.contact = request.POST["tmp_contact"]
profile.receiver = request.POST["tmp_receiver"]
request.session[DRAFT_PROFILE_KEY] = profile
next = request.POST.get("next", '')
if not next:
raise Exception("No any next page")
return HttpResponseRedirect(next)
示例2: save
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import name [as 别名]
def save(self, request):
profile = Profile.objects.get(user=request.user)
if profile is None:
profile = Profile(user=request.user)
profile.name = self.cleaned_data.get("name")
profile.sex = self.cleaned_data.get("sex")
profile.contact = self.cleaned_data.get("contact")
profile.addr = self.cleaned_data.get("addr")
profile.receiver = self.cleaned_data.get("receiver")
#profile.city = self.getCity()
#profile.website = self.cleaned_data.get("website")
#profile.spacename = self.cleaned_data.get("spacename")
profile.desc = self.cleaned_data.get("desc")
profile.save()
profileUpdated.send(sender=profile.__class__, request=request, profile=profile)
return profile
示例3: after_signup
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import name [as 别名]
def after_signup(self, request, user, emailAddress, **kwargs):
profile = None
try:
profile = Profile.objects.get(user=user)
except Profile.DoesNotExist:
profile = Profile(user=user)
profile.name = self.cleaned_data.get("nickname")
#profile.city = City.objects.getById(id=2) #TODO, load from cities cache
profile.save()
#=======================================================
#code in the bookstore
'''为注册用户创建购物车'''
try:
cart = Cart.objects.get(owner=profile)
except Cart.DoesNotExist:
cart = Cart(owner=profile)
cart.save()
示例4: load_player
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import name [as 别名]
def load_player(self, member_url, team, char_name=None):
""" Loads player and team membership data, and adds as member to team. Return profile, membership """
try:
member_d = self.visit_url(member_url)
except IOError:
profile_name = " ".join((word.capitalize() for word in member_url.strip("/").split("/")[-1].split("-")))
print("Page not found, constructing from {0} name and {1} charname".format(profile_name, char_name))
# create profile and membership
profile, created = Profile(name=profile_name, user=self.master_user), True
profile.save()
membership = TeamMembership(team=team, profile=profile, char_name=char_name, active=False)
membership.save()
return profile, membership
if "Player not found in database" in tostring(member_d):
print("Player not found...skipping", file=self.stdout)
return
info_ps = member_d.cssselect('.content-section-1 p')
info_h3s = member_d.cssselect('.content-section-1 h3')
profile_name = info_ps[1].text
if char_name is None:
char_name = info_ps[4].text
if "." in char_name:
char_name = char_name.split(".", 1)[0]
if Profile.objects.filter(name=profile_name).count():
profile, created = Profile.objects.get(name=profile_name), False
membership, membership_created = TeamMembership.objects.get_or_create(team=team, profile=profile, defaults={'char_name': char_name})
membership.char_name = char_name
else:
try:
membership = TeamMembership.objects.get(team=team, char_name=char_name)
profile, created = membership.profile, False
except TeamMembership.DoesNotExist:
# create profile and membership
profile, created = Profile(name=profile_name, user=self.master_user), True
profile.save()
membership = TeamMembership(team=team, profile=profile, char_name=char_name)
print(created, file=self.stdout)
profile.name = profile_name
member_photo_url = info_ps[0].cssselect('img')[0].get('src')
if member_photo_url != self.unknown_photo:
filename = slugify(profile.name) + posixpath.splitext(member_photo_url)[1]
profile.photo.save(filename, ContentFile(urllib2.urlopen(member_photo_url).read()))
if info_ps[3].text:
profile.title = info_ps[3].text
if info_ps[-1].text: # deal with blank race
if info_h3s[-1].text.strip().lower() == "champion":
membership.champion = info_ps[-1].text.strip()
else:
try:
membership.race = info_ps[-1].text[0].upper()
membership.clean_fields()
except ValidationError:
membership.race = None
try:
membership.questions_answers = tostring(member_d.cssselect('div.content-section-2 ol')[0])
except:
pass
try:
profile.full_clean()
except ValidationError as e:
print("Profile did not validate! {profile_name} {e}".format(profile_name=profile_name.encode('ascii', 'ignore'), e=e), file=self.stderr)
else:
profile.save()
membership.save()
return profile, membership