Hi,
i have a hard time figuring out why this form in not loaded on the template. There is no error but the form is not loading. Please advise what i am missing here.
view.py
def addcontact(request):
if request.method=='POST':
form =ContactForm(request.POST)
if form.is_valid():
form.save()
return HttpResponse('Success')
else:
form =ContactForm()
return render(request,'addcontact.html',{'form':form})
form.py
class ContactForm(forms.ModelForm):
class Meta:
model =contacts
fields = ('First_Name', 'Last_Name', 'Department','Extension')
addcontact.html
<form method="post" action="">
{% csrf_token %}
{{ form }}
<button type="submit">Submit</button>
</form>