我正在用Django处理普通的脆皮形式。我将表单更改为多步骤表单,现在提交不起作用。因此,当我单击提交数据时,不会将其存储在数据库中。 更新后的模板如下所示:index.html index.html
<ul id="progressbar">
<li class="active">Account Setup</li>
<li>Social Profiles</li>
<li>Personal Details</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Help me know you better</h2>
<h3 class="fs-subtitle">This is step 1</h3>
{{ form.associate_image|as_crispy_field}}
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
{{ form.title|as_crispy_field}}
{{ form.client|as_crispy_field }}
{{ form.lob|as_crispy_field }}
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Personal Details</h2>
<h3 class="fs-subtitle">We will never sell it</h3>
{{ form.gender|as_crispy_field }}
{{ form.phone_number|as_crispy_field }}
<textarea name="address" placeholder="Address"></textarea>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" name="submit" id="submit-award" class="submit action-button" value="Submit" />
</fieldset>
这是查看功能:
views.py
@login_required
def save_information(request):
associate_id = id_to_numeric(request.user.username)
ldap = Ldap()
current_user = UserDetails.objects.filter(associate_nbr=associate_id)
if current_user.exists():
current_user.delete()
associate_details = ldap.search(associate_id=associate_id)[0]
details = UserDetails(
associate_name=associate_details['name'],
associate_nbr=associate_id,
associate_email=associate_details['email'],
associate_department_id=id_to_numeric(associate_details['department']),
associate_mgr=associate_details['xxx'],
associate_exec=associate_details['xxx'],
associate_org=associate_details['org'],
associate_image=request.FILES['associate_image'],
gender=request.POST['gender'],
title=request.POST['title'],
client=request.POST['client'],
lob=request.POST['lob'],
phone_number=request.POST['phone_number'] ,
)
details.save()
return redirect('/?submit=true')