On Fri, Jan 18, 2013 at 3:38 PM, Nick <nkolat...@gmail.com> wrote:
> This is my first django project outside of the tutorials and it's
> frustrating to stumble over something so simple.
>
> I'm getting this error when I try to add a product:
>>
>> DatabaseError at /admin/products/product/add/
>>
>> table products_product has no column named pub_date
>
>
> This is what my models.py file looks like:
>>
>> from django.db import models
>>
>> class Product(models.Model):
>>     name = models.CharField(max_length = 200)
>>     desc = models.TextField()
>>     pub_date = models.DateTimeField()
>>
>>     def __unicode__(self):
>>         self.name
>
>
> ./manage.py sqlall products returns:
>>
>> BEGIN;
>> CREATE TABLE "products_product" (
>>     "id" integer NOT NULL PRIMARY KEY,
>>     "name" varchar(200) NOT NULL,
>>     "desc" text NOT NULL,
>>     "pub_date" datetime NOT NULL
>> )
>> ;
>> COMMIT;
>
>
> It's all very simple and nothing is special about what I have done. Sorry in
> advance if you guys have dealt with noob questions like this a hundred
> times.
>

syncdb creates tables in the database if they do not exist.

syncdb does not alter existing tables in the databases.

If you would like to automate the work of altering your database
tables, there is an app called django-south which you can use to
inspect your models and database, and generate migration scripts to
update the database so that it corresponds with your models. Google
knows more about this.

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 at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to