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 I'm getting 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:
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. This doesn't make any sense to me. This is part of huge Django app. Any ideas what kind situation could cause this? (is circular dependency possible for example?)
Update:
What I forgot to mention that this code has been running four years in production without any troubles. Just some recent unrelated edits triggered this error.