R
R
Ruslan2016-05-19 15:58:59
MySQL
Ruslan, 2016-05-19 15:58:59

How to enter a field in the database correctly?

After adding a field to the database, let's say in products:
1) I add a field to the table
2) I write code in the place where I want to add
3) I enter information into locale
4) After that, you need to do:
- python manage.py schemamigration
- python manage .py migrate
-./gunicorn stop
./gunicor start
will keep the data in place and just update the tables, right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2016-05-19
@nsd7

You don't have tables, you have models and objects.
You add a field to the model. Two options are possible here:
1) NULLable field or with default value. You don't have to do anything.
2) Another case - you need to specify the field value for all already created objects.
In any case, do
./manage.py makemigrations
If your case is the second, specify a value, then
./manage.py migrate
Reboot the WSGI server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question