Hello, I wanted to add a new attribute to my existing Django model, but I get:
Exception Type: OperationalError
Exception Value: table myapp_screen has no column named caption
I know I can't just add new values to classes when there are existing objects, but I've flushed my database before that and still I am getting this exception. Here's how my models file look like:
from django.db import models
import os
def get_screens_upload_path(instance, filename):
return os.path.join(
"screens", "%s" % instance.project.tag, filename)
class Project(models.Model):
name = models.CharField(max_length=50)
tag = models.CharField(max_length=20)
date_started = models.DateField()
date_finished = models.DateField()
description = models.TextField()
link = models.URLField(blank=True)
def __str__(self):
return self.name
class Screen(models.Model):
project = models.ForeignKey(Project)
caption = models.CharField(max_length=50)
image = models.ImageField(upload_to=get_screens_upload_path)
Everything was fine before I added 'caption' to my Screen model, then it all collapsed. Moreover, when i run
python manage.py inspectdb
it returns me my model without new 'caption' attribute:
class MyappScreen(models.Model):
id = models.IntegerField(primary_key=True)
project = models.ForeignKey(MyappProject)
image = models.CharField(max_length=100)
class Meta:
db_table = u'myapp_screen'
I am guessing it has something to do with my migrations, but what I thought was that pythonanywhere is migrating every changes each time I reload my web. Isn't that so?
@EDIT: I forgot to say, that
python manage.py syncdb
says there is no problem :(