从 Django 迁移中排除应用程序



有没有办法从 Django 迁移中排除应用程序的模型?我知道用managed = False更改模型元选项是一种选择,但每次都需要编辑很多模型。有没有办法指定我不想迁移其模型的应用?

> 从应用程序迁移目录中删除__init__.py文件应该可以工作。

从设置中已安装的应用中移除应用。

如果您将数据库路由器与

def allow_migrate(self, db, app_label, model_name=None, **hints):
return False

例。

class FilemakerRouter:
"""
A router to control all database operations on models in the
filemaker application.
"""
def db_for_read(self, model, **hints):
"""
Attempts to read filemaker models go to filemaker.
"""
if model._meta.app_label == 'filemaker':
return 'filemaker'
return None
def db_for_write(self, model, **hints):
"""
Attempts to write filemaker models go to filemaker.
"""
if model._meta.app_label == 'filemaker':
return 'filemaker'
return None
def allow_relation(self, obj1, obj2, **hints):
"""
Allow relations if a model in the filemaker app is involved.
"""
if obj1._meta.app_label == 'filemaker' or 
obj2._meta.app_label == 'filemaker':
return True
return None
def allow_migrate(self, db, app_label, model_name=None, **hints):
return False

搜索鸭鸭果了解更多详情

最新更新