class B(models.Model):
whatever = models.TextField(blank=True)
@staticmethod
def are_we_ok():
return False
class A(models.Model)
text = models.TextField(blank=True)
@staticmethod
def is_everything_ok():
if not B.are_we_ok():
raise B.DoesNotExist
A.is_everything_ok()
Why am I getting the error:
File "asdf/models.py", line x, in is_everything_ok
if not B.are_we_ok():
AttributeError: 'NoneType' object has no attribute 'are_we_ok'
However, if I do this:
class A(models.Model)
text = models.TextField(blank=True)
@staticmethod
def is_everything_ok():
from asdf.models import B
if not B.are_we_ok():
raise B.DoesNotExist
it works. That makes no sense to me. This is part of the huge Django app. Any ideas on what situation might cause this? (Is circular dependence possible, for example?)
Update:
What I forgot to mention is that this code has been working for four years in production without any problems. Only some recent unrelated changes caused this error.
xoopp source
share