Django 模型 class 在管理器中 None

Django model class is None in manager

我的服务器 运行 一个 Django 应用程序出现了一个非常奇怪的错误。该错误无法在我的本地开发服务器上重现。

我有这个模型和它的经理:

class CardManager(models.Manager):

    def get_by_identifier(self, card_identifier):
        ...
        for possible_suit in Card.SUITS:
            ...

class Card(models.Model):
    objects = CardManager()
    SUITS = ((1, 'Clubs'), ...)

这是错误:

AttributeError at /game/playcard/2/S1/

'NoneType' object has no attribute 'SUITS'

和回溯:

File "local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
    115. response = callback(request, *callback_args, **callback_kwargs)
File "local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
    25. return view_func(request, *args, **kwargs)
File "views.py" in play_card
    155. card = Card.objects.get_by_identifier(card_identifier)
File "models.py" in get_by_identifier
    16. for possible_suit in Card.SUITS:

运行 Django 1.5(是的,我知道),Python 2.7 和 uwsgi

有什么想法吗?我倾向于特定于 uwsgi 的东西,因为我无法在我的本地机器上复制它,但我不知道去哪里看...

谢谢!

使用self.model从管理器访问模型:

for possible_suit in self.model.SUITS:
    ...