Thanks Daniel. Before trying that, I went nto the python shell, imported the DataTable model, and tried DataTable.objects.all(), and got the error: DatabaseError: no such column: myapp_datatable.datFile. I tried re-running syncdb, but still get the same error. Am I using reserved names here, or is there another issue with my code? These are the most logical names for what I am trying to do. Many thanks in advance.
Regards, Nigel Legg 07914 740972 http://www.treavnianlegg.co.uk http://twitter.com/nigellegg http://uk.linkedin.com/in/nigellegg On 7 July 2013 18:27, Daniel Roseman <[email protected]> wrote: > On Saturday, 6 July 2013 12:07:34 UTC+1, Nigel Legg wrote: > >> I have the following code: >> 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 DataTableForm(forms.ModelForm)**: >> >> class Meta: >> >> model = DataTable >> >> views.py: >> def datatables(request): >> if request.method == 'POST': >> form = DataTableForm(request.POST) >> if form.is_valid(): >> form.save() >> return redirect('myapp/tabspec.html') >> else: >> form = DataTableForm() >> return render(request, 'myapp/datatables.html', { >> 'form': form, >> }) >> >> def tabspec(request): >> try: >> datFile = DataTable.datFile >> context = Context({ >> 'datFile': datFile, >> }) >> except DataTable.DoesNotExist: >> raise Http404 >> return HttpResponse(template.render(**context)) >> >> The DataTable view shows, as a form; I enter the values for the ields, >> when I click the button, I get the error "type object 'DataTable' has no >> attribute 'datFile'". I thought maybe I should be referring to >> DataTableForm.datFile, but this gave the same error. >> I am confused, could any one tell me where I am going wrong? >> Regards, >> Nigel Legg >> 07914 740972 >> http://www.treavnianlegg.co.uk >> http://twitter.com/nigellegg >> http://uk.linkedin.com/in/**nigellegg<http://uk.linkedin.com/in/nigellegg> >> >> > datFile (terrible name, by the way) is a field on a DataTable *instance*. > You need to pass an ID value to the tabspec view (via the URL) from your > form view, then use DataTable.objects.get(pk=id) in that tabspec view. > -- > DR. > > -- > 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 http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- 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 http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.

