I have a CharField type with a choices field as follows:
class Thing(models.Model):
def __unicode__(self):
return self.name
A = 'a'
B = 'b'
C = 'c'
TYPE_CHOICES = (
(A, 'a'),
(B, 'b'),
(C, 'c'),
)
...
type = models.CharField(max_length = 1, choices=TYPE_CHOICES)
...
Now when I try to access a page add/thing I am getting a DatabaseError at /path/to/thing/add/
column “type” of relation “place_thing” does not exist
I checked the database (postgres), and I found that type was not a column as said in the error.
Why is the type field not being added when I sync or migrate the database?
How can I create the columns ‘TYPE_CHOICES’ and ‘type’ in my database (postgres)?
Can someone explain to me what would be created by the database for class Thing?
Thank you
katie
I ended up using
ALTER TABLE table_name ADD COLUMN type varchar(30);
and this worked
i guess the TYPE_CHOICES column was already made
thanks