本文整理汇总了Python中models.Form.put方法的典型用法代码示例。如果您正苦于以下问题:Python Form.put方法的具体用法?Python Form.put怎么用?Python Form.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Form
的用法示例。
在下文中一共展示了Form.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: registration
# 需要导入模块: from models import Form [as 别名]
# 或者: from models.Form import put [as 别名]
def registration(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
data = form.cleaned_data
model = Form()
model.fullname = data['fullname']
model.wcaid = data['wcaid']
model.country = data['country']
model.city = data['city']
model.email = data['email']
model.tshirt = data['tshirt']
model.nick = data['nick']
model.accomodation = data['accomodation']
model.born = datetime.date(int(data['bornyear']), int(data['bornmonth']), int(data['bornday']))
model.events = [str(ev) for ev in data if ev.startswith('ev_') and data[ev] == True]
model.status = 1
model.put()
return HttpResponseRedirect('/thanks')
else:
form = RegistrationForm()
return render_to_response('registration.html', {
'form': form,
'page': 'registration',
'years': range(1900, 2009),
'months': range(1, 13),
'days': range(1, 32),
})
示例2: post
# 需要导入模块: from models import Form [as 别名]
# 或者: from models.Form import put [as 别名]
def post(self):
try:
jsondata = json.loads(self.request.body)
except UnicodeDecodeError:
jsondata = json.loads(self.request.body,encoding='latin-1')
logging.info(jsondata.keys())
form = Form()
procfields = []
for i,f in enumerate(jsondata['fields']):
procfields.append({
'name': 'field{}'.format(i),
'Descr': f['Descr'],
'Val': f['Val']
})
form.creator = jsondata['creator']
form.until = datetime.datetime.now() + datetime.timedelta(hours=jsondata['duration'])
form.hashtag = jsondata['hashtag']
form.fields = procfields
form.description = jsondata['description']
form.authenticated = not bool(jsondata['authenticated'])
form.info = jsondata['info']
form.put()
示例3: post
# 需要导入模块: from models import Form [as 别名]
# 或者: from models.Form import put [as 别名]
def post(self):
form = Form()
self._update_form_from_request(form)
form.put()
logging.info("Created form '%s'" % form.key.urlsafe())
self.redirect(self.uri_for('forms-list'))