OK. I will change it to an EmailField and see if that helps. However I have a further question. When making changes like this to existing tables, do I always need to run the syncdb command to make sure that everything is updated properly then?
On Feb 14, 11:28 am, delegb...@dudupay.com wrote: > Tom, > > How does he do that? > Sent from my BlackBerry wireless device from MTN > > > > -----Original Message----- > From: Tom Evans <tevans...@googlemail.com> > > Sender: django-users@googlegroups.com > Date: Mon, 14 Feb 2011 17:25:58 > To: <django-users@googlegroups.com> > Reply-To: django-users@googlegroups.com > Subject: Re: Model Codng/Model Usage Pitfall? > > On Mon, Feb 14, 2011 at 5:21 PM, hank23 <hversem...@stchas.edu> wrote: > > I have coded a table which looks like this: > > > class Comment(models.Model): > > title = models.CharField(max_length=1,choices=TITLE_CHOICES) > > firstname = models.CharField(max_length=15) > > lastname = models.CharField(max_length=25) > > commenttext = models.CharField(max_length=500) > > emailaddress = models.CharField(max_length=30) > > commentdate = models.DateTimeField() > > > and when I try to save a new entry to it like this: > > > newtitle = form.cleaned_data['title'] > > newfirstname = form.cleaned_data['firstname'] > > newlastname = form.cleaned_data['lastname'] > > newcommenttext = form.cleaned_data['commenttext'] > > newemailaddress = form.cleaned_data['emailaddress'] > > newcommentdate = form.cleaned_data['commentdate'] > > newcomment = Comment(title=newtitle, > > firstname=newfirstname, lastname=newlastname, > > commenttext=newcommenttext, emailaddress=newemailaddress, > > commentdate=newcommentdate) > > newcomment.save() > > > I'm getting this error: > > > DatabaseError at /polls/addcomment/ > > table polls_comment has no column named emailaddressRequest Method: > > POST > > Request URL:http://127.0.0.1:8000/polls/addcomment/ > > Django Version: 1.2.4 > > Exception Type: DatabaseError > > Exception Value: table polls_comment has no column named emailaddress > > Exception Location: C:\Python27\lib\site-packages\django\db\backends > > \sqlite3\base.py in execute, line 200 > > Python Executable: C:\Python27\python.exe > > Python Version: 2.7.1 > > Python Path: ['C:\\Users\\hversemann\\djangoprojects\\mysite', 'C:\ > > \Python\\Lib', 'C:\\Python\\Lib\\site-packages', 'C:\\Users\\hversemann > > \\Desktop\\PythonSourceFiles', 'C:\\Users\\hversemann\\djangoprojects\ > > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > > Server time: Mon, 14 Feb 2011 11:19:06 -0600 > > > which is obviously wrong. So why does django not think I have that > > field defined? Thanks in advance for the help. > > Django does not take care of maintaining the structure of your tables. > If you change your model definition to add a new attribute, django > will not update your database to add the new column to your table, you > must do it manually. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.