lazybird/django-solo

Crash on migrations

deusesx opened this issue · 4 comments

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 ?

Don'r run it on module level or make it lazy

So I just need to run ModelName.get_solo() on every method/function where I need it?

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.

Thank you very much, you saved the day!