This is causing the error because it gets called when the class is first imported which happens when Django sets up its environment and before the migrations take place.

I suggest you make this lazy.