是否可以在Django项目之外更改"migrations"文件夹的位置? [英] Is it possible to change the 'migrations' folder's location outside of the Django project?
本文介绍了是否可以在Django项目之外更改"migrations"文件夹的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做的是更改django项目中特定应用程序的默认迁移路径,以将其放置在项目本身之外,但保持透明性,并保持使用 makemigrations 和迁移.是否可以?如果是,怎么办?
what i'm trying to do is to change the default path for migrations for a specific application in a django project to put it outside the project itself but keeping it transparent, keeping use of makemigrations and migrate. Is it possible? if yes, how?
推荐答案
Django的 MIGRATION_MODULES
设置.它允许您为每个应用程序指定不同的迁移模块.该模块可以在Django项目之外,只需在python路径上即可.
Django has a MIGRATION_MODULES
setting. It allows you to specify a different module for migrations per app. The module can be outside of the Django project, it just needs to be on your python path.
MIGRATION_MODULES = {'myapp': 'othermodule.db_migrations'}
这篇关于是否可以在Django项目之外更改"migrations"文件夹的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文