Answer the question
In order to leave comments, you need to log in
Why is the form submission not saved to the database?
'dont save' fires
def House(request):
if request.method == 'POST':
form = Hous(request.POST, request.FILES)
if form.is_valid():
print("is valid")
form.save()
redirect('/')
else:
return HttpResponse('dont save')
else:
form = Hous()
return render(request, 'front.html', {'form':form})
forms.py:
from django import forms
from .models import Hous
class Hous(forms.ModelForm):
class Meta:
model = Hous
fields ='__all__'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question