I'm trying to follow the documentation on using forms to save data tot he database. vmware is my app name. Nothing is showing up on my index page though. I'm not sure why can anyone help me the documentation isn't clear it bounces everywhere between two different methods without really defining how to call it in your views.py
My template <form action="{{ vmware }}" method="post" accept-charset="utf-8"> {{form.as_p}} <p><input type="submit" value="Add"></p> </form> views.py def index(request): customers = Customer.objects.all() ctx = { 'customers':customers } return render_to_response('index.html', ctx) if request.method == 'POST': form = CustomerForm(request.POST) instance = form.save(commit=False) instance.vmware = vmware.objects.get(title=offset) instance.save() return HttpResponseRedirect('/') else: form = CustomerForm() return render_to_response('index.html',{'form':form},context_instance=RequestContext(request)) 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 class Vms(models.Model): VMNAME = models.CharField(max_length=200) VMSTATUS = models.CharField(max_length=200) CUSTOMERID = models.ForeignKey(Customer) def __unicode__(self): return self.VMNAME class Vmspecs(models.Model): CPUS = models.CharField(max_length=200) CORES = models.CharField(max_length=200) MEMORY = models.CharField(max_length=200) HDSPACE = models.CharField(max_length=200) OS = models.CharField(max_length=200) UPTIME = models.CharField(max_length=200) VMID = models.ForeignKey(Vms) CUSTOMERID = models.ForeignKey(Customer) def __unicode__(self): return unicode(self.VMID) class CustomerForm(ModelForm): class Meta: model = Customer fields = ['NAME', 'WEBSITE', 'PHONE', 'EMAIL', 'ADDRESS', 'VMIDS'] -- 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/e172d870-ccf5-43cb-a3bf-90f5f07d296d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.