> > Below is my code. I am trying to generate a customer signup form from the > Customer model in the models.py file. > Below I have created forms.py which is the script that will generate the form data based on what is in the models.py file. Then in views. I call that forms.py file to run and display the form data. However no fields are populated just the submit button shows.
*forms.py* from django import forms from .models import Customer class SignUpForm(forms.ModelForm): class Meta: model = Customer *models.py* class Customer(models.Model): NAME = models.CharField(max_length=200) WEBSITE = models.CharField(max_length=200) PHONE = models.CharField(max_length=200) EMAIL = models.CharField(max_length=200) ADDRESS = models.CharField(max_length=200) VMIDS = models.CharField(max_length=200) def __unicode__(self): return self.NAME *views.py* from django.shortcuts import render from django.http import HttpResponse from vmware.models import Customer from django.shortcuts import render_to_response from vmware.models import Vms from .forms import SignUpForm def index(request): form = SignUpForm(request.POST or None) if form.is_valid(): save_it = form.save(commit=False) save_it.save() customers = Customer.objects.all() ctx = { 'customers':customers } return render_to_response('index.html', ctx) *index.html* <form action='' method='POST'> {% csrf_token %} {{ form.as_p }} <p><input type="submit" value="Add"></p> </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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ec521775-9a04-4989-802a-882f90d65a88%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.