Reputation: 811
I have problems, I don't know how to update database...
So here is my problem: I updated my app models.py with one line *yrs = models.CharField(max_length=4)*:
from django.db import models
class Books(models.Model):
title = models.CharField(max_length=150)
author = models.CharField(max_length=100)
*yrs = models.CharField(max_length=4)*
read = models.CharField(max_length=3)
def __str__(self):
return self.title + " / " + self.author + " / " + **self.yrs** + " / " + self.read + " "
So, but now I get error:
Exception Type: DatabaseError
Exception Value: no such column: books_books.yrs
So, do you know how I can fix it? Thank you ;)
Upvotes: 0
Views: 179
Reputation: 4855
You can use South to migrate your data.
If you don't care about your existing data, just remove your database file (in case of sqlite3), and run
python manage syncdb
again
South is pretty easy to use and the tutorial is giving you a lot of real examples.
If South doesnt sound appealing to you, you can also alter directly your table using dbshell
python manage.py dbshell
ALTER TABLE <appname_modelname> ADD COLUMN <column_type> DEFAULT '';
Upvotes: 2