How to avoid "no such column" error when I add a new property to a model?

197 views
Skip to first unread message

callum

unread,
Jan 11, 2012, 5:26:32 AM1/11/12
to Django users
I created an "Article" model with a few simple properties. I ran
syncdb, and set up the Django admin site, and added
"admin.site.register(Article)" in admin.py. Using the Django admin
site, I created an article by filling in the form.

I then went into models.py and added another property. I ran syncdb
again, ran the server again, then when I opened the Django admin site
again, I got the "no such column" error.

When I Googled this, the only obvious solutions I found were to reset
the app, or at least drop the database table that changed, and start
over.

But how do I do this without losing my data?

Daniel Roseman

unread,
Jan 11, 2012, 5:35:39 AM1/11/12
to django...@googlegroups.com
I can't believe your Googling didn't reveal the canonical solution:
--
DR. 

Python_Junkie

unread,
Jan 11, 2012, 3:30:35 PM1/11/12
to Django users
For those who do not want to use another abstraction module, just use
sql on the database to add the column.

Look up the alter table command for the database that you are using.

Andre Terra

unread,
Jan 11, 2012, 3:46:27 PM1/11/12
to django...@googlegroups.com
Or use a GUI tool like PgAdmin[0] for PostgreSQL, which is packaged into most psql distributions.


Cheers,
AT

[0] http://www.pgadmin.org/



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


David Harks

unread,
Jan 13, 2012, 7:50:20 AM1/13/12
to django...@googlegroups.com

Check out South. http://south.aeracode.org

Reply all
Reply to author
Forward
0 new messages