本文整理汇总了Python中profiles.models.Profile.organization方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.organization方法的具体用法?Python Profile.organization怎么用?Python Profile.organization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profiles.models.Profile
的用法示例。
在下文中一共展示了Profile.organization方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_team
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import organization [as 别名]
def create_team(request, username):
"""
Display the TeamCreationForm
"""
if request.method == 'POST':
form = TeamCreationForm(request.POST)
if form.is_valid() and request.user.pk == form.cleaned_data['creator']:
team = User.objects.create_user(form.cleaned_data['name'])
team_creator_attrs = dict(
team=team,
user=request.user,
permission=4,
creator=True
)
team_creator = TeamMember(**team_creator_attrs)
team_creator.save()
try:
profile = team.get_profile()
except Profile.DoesNotExist:
profile = Profile(user=team)
profile.organization = True
profile.creator_id = request.user.pk
profile.save()
HttpResponseRedirect(reverse('update_team', args=(form.cleaned_data["name"],)))
else:
form = TeamCreationForm(initial={'creator': request.user.pk})
return render_to_response('teams/team_create.html',
{'form': form, 'username': username},
context_instance=RequestContext(request))