0

I am executing a query to auth.models.User in my local_settings, for the fact that I need a User instance in several tests.

from django.contrib.auth.models import User
TEST_USER = User.objects.all()[0]

This raised an error:

No module named simple_backend

With that, the connection to the Django development server is dropped. What does this message mean, and how does it happen?

4

1 回答 1

1

You don't say where local_settings is imported, but if it's in the main settings.py, then you can't do that. Settings is where the whole Django project is being set up, and it doesn't make sense to use the database engine that's being set up in the file that's setting it up.

If you need something in several tests, define a test class that sets that value up, then make all your other tests subclass that class.

于 2011-10-26T15:01:45.520 回答