Reputation: 1069
Django 3.2.6
I'd like some models not to made migrations at all.
Is it possible?
I tried:
1. https://docs.djangoproject.com/en/3.2/ref/models/options/#managed
class Meta: managed = False
2.
class PrimaryReplicaRouter:
special_model_names = {'generalsettings', 'generalsettings', }
def allow_migrate(self, db, app_label, model_name=None, **hints):
if model_name in self.special_model_names:
return False
return True
It doesn't help: migrations are created.It doesn't migrate. But migrations become unnecessarily noisy.
I quote from here:
https://docs.djangoproject.com/en/3.2/topics/db/multi-db/#allow_migrate
makemigrations always creates migrations for model changes, but if allow_migrate() returns False, any migration operations for the model_name will be silently skipped when running migrate on the db.
Well, I don't want to make migrations for some models. Is it possible?
Upvotes: 3
Views: 1613
Reputation: 1
you must to delete in your file your models migration file before apply managed=False
Upvotes: 0
Reputation:
In you class, add following line:
class Meta:
abstract = True
If any class Meta is abstract true, django doesn't create migration file for that models
Here you go for more details: https://docs.djangoproject.com/en/3.2/ref/models/options/#abstract
Upvotes: 4