O
O
Oleg2019-09-02 12:20:48
Django
Oleg, 2019-09-02 12:20:48

When to use migrate and makemigrations?

I'm probably a little dumb, but I didn't find a direct answer to my question (probably because my English is very bed) As I understood from the documentation makemigrations - creates SQL code but does not apply it, and migrate - applies the migration file created by makemigrations and already applies it to SQL, after which a snapshot is created in version control. The question that torments me is: It turns out that you always need to use makemigrations and then migrate for any changes in the database? Even if you changed the field? What if you changed the field and applied .save()? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yura Khlyan, 2019-09-02
@pako1265

You need to do migrations when you change a field in a model (not a model instance). And after the migrations are done, it’s best to apply them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question