Crash on migrations
deusesx opened this issue · 4 comments
deusesx commented
I have an issue with running manage.py migrate
- it tries to run ModelName.get_solo()
method and fails with database error.
App structure:
--- models.py
--- helpers/
----- bot.py
In bot.py I'm doing:
from appname.models import ModelName
config = ModelName.get_solo()
How to prevent execution of ModelName.get_solo()
while manage.py migrate
?
vparitskiy commented
Don'r run it on module level or make it lazy
deusesx commented
So I just need to run ModelName.get_solo() on every method/function where I need it?
vparitskiy commented
Yes
But maybe you could do something like this if you want it on module level.
config = SimpleLazyObject(ModelName.get_solo)
Just don't access this variable because it will cause it's evaluation.
deusesx commented
Thank you very much, you saved the day!