Django:代理元类忽略 verbose_name_plural

发布于 2024-09-14 03:20:29 字数 703 浏览 4 评论 0原文

Django-admin 正在多元化我作为代理类运行的模型。

这里的正常情况工作正常:

class Triviatheme(models.Model):
    [  ... elided ... ]
    class Meta:
        db_table = u'TriviaTheme'
        verbose_name_plural='trivia themes'

但是对于主内容表,我有一个名为“Content”的父模型和一个代理类:

class News(Content):
    DTYPE='News'
    class Meta:
        verbose_name_plural='News'
        proxy = True

但是内容中的元仍然复数“News”导致“Newss”,所以它忽略verbose_name_plural 字段,但不是 proxy 字段。

同样,重写父类中的字段似乎也没有效果。我缺少什么?有没有更好的方法来实现带有鉴别器列的大表模型?

请注意,这是从不同的应用程序对数据库进行逆向工程,因此模型设置得很好,我不能只更改架构。

编辑

我使用的是 python 2.6 / Django 1.2.1

我还使用 Manager 类来处理鉴别器,但它仍然不起作用。

Django-admin is pluralizing a model that I have running as a proxy class.

The normal case here works fine:

class Triviatheme(models.Model):
    [  ... elided ... ]
    class Meta:
        db_table = u'TriviaTheme'
        verbose_name_plural='trivia themes'

But for a main content table, I have a parent model called 'Content', and a proxy class:

class News(Content):
    DTYPE='News'
    class Meta:
        verbose_name_plural='News'
        proxy = True

But with the Meta in Content is still pluralizing 'News' resulting in 'Newss', so its ignoring the verbose_name_plural field, but not the proxy field.

Similarly, overriding the field in the parent class seems to have no effect. What am I missing? Is there a better way of implementing a large table model with a discriminator column?

Note that this is reverse engineering a DB from a different app, so the model is pretty well set and I can't just change the schema.

edit:

I'm on python 2.6 / Django 1.2.1

I'm also using a Manager class to handle the discriminator, but its still not working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故人如初 2024-09-21 03:20:29

FWIW 我用 Django 1.1.1 和 Django 1.2.1 对此进行了测试,在这两种情况下它都按预期工作。

FWIW I tested this with Django 1.1.1 and Django 1.2.1 and it worked as expected in both cases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文