简体   繁体   English

Django:核心库和向南迁移

[英]Django: Core library and South migrations

I'm currently working on a django project which tends to get pretty complex in time. 我目前正在进行一个django项目,该项目往往会变得很复杂。 Therefore I'm planning to encapsulate basic core models and utilities that are going to be reused throughout the application in a separate space. 因此,我计划将将在整个应用程序中重用的基本核心模型和实用程序封装在单独的空间中。 Since these models are mostly base models needed by other apps, imho there's no need to create a django app and instead place them in an standard python package (so the package is acting just like a simple library). 由于这些模型主要是其他应用程序所需的基本模型,因此恕我直言,无需创建django应用程序,而是将它们放置在标准python包中(因此,该包的行为就像一个简单的库)。

Since I'm using south for migrations I'm running into problems when not creating an app and instead use my 'library', because south only considers apps for migrations. 由于我使用South进行迁移,因此在不创建应用程序而使用我的“库”时遇到了问题,因为South仅考虑将应用程序用于迁移。

What is the django way to avoid this 'problem' and to be able to also create migrations for my core models? 避免这种“问题”并能够为我的核心模型创建迁移的django方法是什么?

Well... the answer is to use apps. 好吧...答案是使用应用程序。

That's what they're for. 那就是他们的目的。 They were designed the way the are exactly because standard modules don't provide the level of integration needed. 之所以设计它们,正是因为标准模块无法提供所需的集成级别。

If you start hacking away on your library to make it work on its own, you'll end up with mess of code and glue about the same size of a django app, but with considerably worse smell. 如果您开始黑客攻击自己的库以使其自己运行,那么最终将产生混乱的代码和胶水,其大小与django应用程序的大小相同,但气味却更差。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM