Adam
Adam

Reputation: 3128

Adding a ManyToManyField field to an existing model

I have a production model and I need to add the following field to it:

tag = models.ManyToManyField(Tags)

The following is not picking up the change:

python manage.py syncdb

And therefore, mymodel_tag table is not being created. I am using Postgres.

What are my options other than dropping the table and recreating it since the application is already on production use.

Upvotes: 1

Views: 414

Answers (1)

alecxe
alecxe

Reputation: 473833

South would definitely help:

South is a tool to provide consistent, easy-to-use and database-agnostic migrations for Django applications.

Note that in Django 1.7 (currently in development stage) South is going to become a part of django (docs).

A good place to start is to go through the tutorial and how to start using South with an existing database page.

Also see:

Note that creating a many-to-many table manually may look like an easy solution/workaround in a short-perspective, but I'd consider switching to south anyway.

Hope that helps.

Upvotes: 1

Related Questions