我有几类课程,例如: band
, Album
, Song
,
title
(有时称为 name
)和 slug
,以及其他类别特定的字段。
我想用南方将其转换成共同基类( article
)的孩子,该类包含每个对象的 标题
和 slug
。 但是,我不知道南方的数据迁移在我的案例中应该如何运作; 您能帮助吗?
我有几类课程,例如: band
, Album
, Song
,
title
(有时称为 name
)和 slug
,以及其他类别特定的字段。
我想用南方将其转换成共同基类( article
)的孩子,该类包含每个对象的 标题
和 slug
。 但是,我不知道南方的数据迁移在我的案例中应该如何运作; 您能帮助吗?
你只需要考虑一下南方对你的模型的改变, 并计划一下。
如果 article
是抽象的类别, 南方将基本上不理会它。 也就是说, 所有字段都看起来像是直接在模型上的字段, 大致上是现在的你。 因此, 唯一会发生的变化是某个模型之前使用 < code> name 的域, 现在它将有一个新的 < code> 标题 字段。 因此, 您应该离开通过系统迁移连接的 < code> name 字段, 然后创建数据迁移, 将其值移动到新的 < code> title 字段, 最后将其移到 < em> another em > schegragration 域。
如果 article
是标准基级(多式继承), 那么您的所有模型都会在文章中找到一个新的 < code> OneToOne Field 。 再一次, 通过系统迁移, 将所有域都留在您的模型上, 然后创建数据迁移, 从而您将运行于每个模型中, 并使用该模型上的旧数据创建 < code> article 例, 并将 < code> article < /code> 例指定为一对一字段。 然后, 您可以在另一个系统迁移中删除旧字段 。
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.
I want to email users an encrypted file from a Django Backend Script (running through manage.py) on Ubuntu. How can I encrypt the data so that it is unreadable by 3rd parties who might intercept or ...
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....
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 ...
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 ...
I m trying to reset a database in Django, using: python manage.py reset app but get the following error: Error: Error: app couldn t be reset. Possible reasons: * The database isn t running or isn ...
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: &...
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 ...