I am getting FATAL: database "xxxxxxxxx" does not exist
during the loading of py.test. This is coming from the loading of the admin forms, where by I have a queryset being passed to a ModelChoiceField
class CustomChoiceField(forms.ModelChoiceField):
def __init__(self, queryset=None, *args, **kwargs):
return super().__init__(SomeModel.objects.limited_qs(), *args, **kwargs)
class SomeModelForm(forms.ModelForm):
some_model = CustomChoiceField()
class Meta:
model = SomeModel
class SomeModelAdmin(admin.ModelAdmin):
form = SomeModelForm
I've tried this with
formfield_overrides = { models.ForiegnKey : {'queryset': ... } }
all result in the same problem with py.test
EDIT
Having the queryset either in the __init__
method or in formfield_overrides
also breaks the migrations.
Note: these all work exactly how I want them to on the server - they just prevent me for running any tests.
How do I get this to pass (w/o conditionally registering my admin stuff ;_; I like tdd)