本文整理汇总了Python中models.Project.user方法的典型用法代码示例。如果您正苦于以下问题:Python Project.user方法的具体用法?Python Project.user怎么用?Python Project.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Project
的用法示例。
在下文中一共展示了Project.user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: newProject
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import user [as 别名]
def newProject(request, projectname, monthlygoal):
print projectname
project = Project()
project.user = request.user
project.name = projectname
if monthlygoal != "":
project.monthlygoal = int(monthlygoal)
goal = project.monthlygoal
else:
goal = "-"
print project
project.save()
print "qwe"
dajax = Dajax()
dajax.remove("#newrow")
row = """<tr id="project{0}">
<td>{1}</td>
<td>{2}</td>
<td>0</td>
<td><a href="javascript:void(0)" onClick="Dajaxice.timemanager.removeProject(removeRow, {{'project': '{0}'}});" class="remove"><i class="icon-remove pull-right"></i></a> <a href="javascript:void(0)" onClick="" class="edit"><i class="icon-pencil pull-right"></i></a></td>
</tr>""".format(project.id, projectname, goal)
print row
dajax.append("#projecttable", "innerHTML", row)
dajax.script("$('#newprojectbutton').show();")
return dajax.json()
示例2: register
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import user [as 别名]
def register(request):
if request.method == 'POST':
a = request.POST.get('action')
if a == 'register':
register_f = RegisterForm(request.POST)
login_f = LoginForm()
if register_f.is_valid():
try:
User.objects.create_user(
register_f.cleaned_data['username'],
register_f.cleaned_data['email'],
register_f.cleaned_data['password'])
except IntegrityError, e:
if 'username' in str(e):
register_f.add_error('username',
'Username is taken')
elif 'email' in str(e):
register_f.add_error('email',
'Email is already registered')
else:
raise e
else:
user = authenticate(
username=register_f.cleaned_data['username'],
password=register_f.cleaned_data['password'])
login(request, user)
Timezone.objects.create(user=user)
project = Project()
project.user = user
project.name = 'default project'
project.description = 'default project description'
project.color = Project.DEFAULT_COLOR
project.save()
return redirect('dashboard')
elif a == 'login':
register_f = RegisterForm()
login_f = LoginForm(request.POST)
if login_f.is_valid():
user = authenticate(
username=login_f.cleaned_data['username'],
password=login_f.cleaned_data['password'])
if user is None:
login_f.add_error('username',
'Wrong credentials')
else:
login(request, user)
return redirect('dashboard')
else:
register_f = RegisterForm()
login_f = LoginForm()
示例3: newproject
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import user [as 别名]
def newproject(request):
basic = get_basic(request)
if request.method == 'POST':
form = ProjectForm(request.user, request.POST, request.FILES)
if form.is_valid():
obj = form.save(commit=False)
obj.user = request.user
obj.save()
form.save_m2m()
return HttpResponseRedirect('/project?id=' + str(obj.id))
else:
proj = Project()
proj.user = request.user
form = ProjectForm(request.user, instance=proj)
return render(request, 'newproject.html', {'form': form, 'basic': basic})