A'zam Mamatmurodov
A'zam Mamatmurodov

Reputation: 370

django 1.5 column doesn't exists

When i added new field to my product model ,it returned error like this-> 'Database Error at "/admin/app/product/" column app_product.product_sold_time does not exist LINE 1: ...duct_buy", "app_product"."product_favorite_send"'

Upvotes: 0

Views: 252

Answers (2)

C14L
C14L

Reputation: 12548

When you add a field to a model and not to the database, then that new field will have no existing column in the database. The new field will not just "magically" have a column appear in the existing database.

So now your have these options with Django 1.5:

  • delete the database and run ./manage.py syncdb again,
  • use South to be able to migrate the database and add columns to existing tables, or
  • upgrade Django to 1.7 or above and use Django's own migrations to add the new column to the existing table.

Upvotes: 1

Vasyl Piellia
Vasyl Piellia

Reputation: 11

You added a new field to you product model, but you have not migrated your DataBase, that's why you get Database Error.

You can upgrade Django using command:

pip install --upgrade django

than you can use django-commands

python manage.py makemigrations
python manage.py migrate

If you do not want to upgrade Django, install South and follow it`s instructions. http://test-driven-django-development.readthedocs.org/en/v2.0/08-south.html

Upvotes: 1

Related Questions