我在我的应用程序中创建了一个表单,我可以在其中获取用户的详细信息。现在我想创建一个可以让我编辑表单的表单。
我的 urls.py:
url(r'^home/editform/(?P<userpk>[^/]+)/$', 'lexuseditform', name='lexuseditform'),)
我的观点.py:
@login_required
def lexuseditform(request,userpk):
if int(userpk) != request.user.pk:
return HttpResponseForbidden()
else:
form = AdultForm()
if request.method == 'POST': # If the form has been submitted...
form = AdultForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
form.save()
redirect_url = reverse('lexus/lexusedited.html')
return HttpResponseRedirect(redirect_url) # Redirect after POST
else:
form = AdultForm() # An unbound form
return render('lexus/lexuseditform.html', {'form': form})
我的模型.py:
class AdultForm(ModelForm):
"""
Edit Profile Information
"""
class Meta:
model = Adult
fields = ('user', 'email','fullname','created')
但我收到一条错误消息:No ReverseMatch: Reverse for 'lexuseditform' with arguments '()' and keyword arguments '{}' not found
似乎无法解决此错误。需要一些帮助...