models.py:
class DataTable(models.Model):
datFile = models.CharField(max_length = 200)
structFile = models.CharField(max_length = 200)
bannerVar = models.CharField(max_length = 50)
stubVar = models.CharField(max_length = 50)
stubNets = models.BooleanField()
def __unicode__(self):
return u'%s %s %s %s' % (self.datFile, self.structFile, self.bannerVar, self.stubVar)
forms.py:class DataTable(models.Model):
datFile = models.CharField(max_length = 200)
structFile = models.CharField(max_length = 200)
bannerVar = models.CharField(max_length = 50)
stubVar = models.CharField(max_length = 50)
stubNets = models.BooleanField()
def __unicode__(self):
return u'%s %s %s %s' % (self.datFile, self.structFile, self.bannerVar, self.stubVar)
class DataTableForm(forms.ModelForm):
class Meta:
model = DataTable
def datatables(request):
if request.method == 'POST':
form = DataTableForm(request.POST)
if form.is_valid():
form.save()
DataTable_id = DataTable.id
return render(request, 'myapp/tabspec/{{DataTable_id}}.html', {
'DataTable_id' : DataTable.id,
})
else:
form = DataTableForm()
return render(request, 'myapp/datatables.html', {
'form': form,
})
if request.method == 'POST':
form = DataTableForm(request.POST)
if form.is_valid():
form.save()
DataTable_id = DataTable.id
return render(request, 'myapp/tabspec/{{DataTable_id}}.html', {
'DataTable_id' : DataTable.id,
})
else:
form = DataTableForm()
return render(request, 'myapp/datatables.html', {
'form': form,
})
When I input data on the form, and click "Confirm Selections", I get
"object DataTable has no attribute 'DataTable_id'"
Should I be using a different method to save the data from the form to the database?
Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment