English 中文(简体)
Django/南方:将不同班级调整为共同基级
原标题:Django/South: Migrating different classes to common base class

我有几类课程,例如: band , Album , Song , title (有时称为 name )和 slug ,以及其他类别特定的字段。

我想用南方将其转换成共同基类( article )的孩子,该类包含每个对象的 标题 slug 。 但是,我不知道南方的数据迁移在我的案例中应该如何运作; 您能帮助吗?

最佳回答

你只需要考虑一下南方对你的模型的改变, 并计划一下。

如果 article 是抽象的类别, 南方将基本上不理会它。 也就是说, 所有字段都看起来像是直接在模型上的字段, 大致上是现在的你。 因此, 唯一会发生的变化是某个模型之前使用 < code> name 的域, 现在它将有一个新的 < code> 标题 字段。 因此, 您应该离开通过系统迁移连接的 < code> name 字段, 然后创建数据迁移, 将其值移动到新的 < code> title 字段, 最后将其移到 < em> another schegragration 域。

如果 article 是标准基级(多式继承), 那么您的所有模型都会在文章中找到一个新的 < code> OneToOne Field 。 再一次, 通过系统迁移, 将所有域都留在您的模型上, 然后创建数据迁移, 从而您将运行于每个模型中, 并使用该模型上的旧数据创建 < code> article 例, 并将 < code> article < /code> 例指定为一对一字段。 然后, 您可以在另一个系统迁移中删除旧字段 。

问题回答

暂无回答




相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签