lundi 29 juin 2015

Django form not visible


Only the button is visible and headings are visible cannot see CharField

forms.py

from django import forms

class NameForm(forms.Form):
    your_name = forms.CharField(label='Your name', max_length=100)

views.py

from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from compare.forms import NameForm

def get_name(request):
   if request.method == 'POST':
      form = NameForm(request.POST)
   if form.is_valid():
      return HttpResponseRedirect('/thanks/')

   else:
      form = NameForm()

   return render(request, 'name.html', {'form': form})

index.htm

    <form action="/your-name/" method="post">
        {% csrf_token %}
        {{ form }}
    <input type="submit" value="Submit" />
    </form>


Aucun commentaire:

Enregistrer un commentaire