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>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5sgnz8VXx%3DOxuTT0A0SZ%3Dpt%3D7Y3e%3DUcNbOdRsJn8ANWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to