0
我在我的應用程序中創建了一個表單,可以在其中查看suer的詳細信息。現在我想創建一個可以讓我編輯表單的表單。在Django中編輯表格
我的urls.py:
我view.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})
我的models.py:
class AdultForm(ModelForm):
"""
Edit Profile Information
"""
class Meta:
model = Adult
fields = ('user', 'email','fullname','created')
但我得到一個錯誤信息: 無ReverseMatch:反轉'lexuseditform'參數'()'和關鍵字參數'{}'找不到
似乎無法解決此錯誤。需要一些幫助...