Nizar Hattab
Nizar Hattab

Reputation: 33

Django Models UnManaged to Managed

Does changing Django Model from managed=False to managed=True affect the data ?

I have a large table of a Model that has managed=False and want to add a new field to it. adding a field using migration can't be done without changing the model to managed=True

Is it safe to just change it to managed=True , migrate the change, then update fields ?

Upvotes: 2

Views: 1789

Answers (1)

Omayer Hasan Marif
Omayer Hasan Marif

Reputation: 364

Yes. It is safe and required. I have read django documentation about your problem. That says that:

Managed option defaults to True, meaning Django will create the appropriate database tables in migrate or as part of migrations and remove them as part of a flush management command. That is, Django manages the database tables’ lifecycles.

If False, no database table creation, modification, or deletion operations will be performed for this model.

If your django model option managed=False then make it managed=True, otherwise your migration of models won't work. For more info read django documentation.

Upvotes: 1

Related Questions