1👍
✅
From different SO answers that I’ve seen, this will do the trick:
import django
django.setup()
and the reason behind it is
Basically, Django has a new way to load installed app. If you load
Django from a Python script (like I was in my custom unit tests), some
initialization needs to be done before proceeding and calling setup()
is how to do it. Aside from that, kudos to the team, my 1.6.2 to 1.7.1
upgrade seems to an hour’s worth of real work.– JL Peyret
Source:stackexchange.com