X
X
xxx2019-01-30 16:17:34
Django
xxx, 2019-01-30 16:17:34

Site matching query does not exist when trying to run tests?

Trying to do

[email protected]2fd625d222bb:/app# ./manage.py test 
Creating test database for alias 'default'...
Got an error creating the test database: database "test_app" already exists

Type 'yes' if you would like to try deleting the test database 'test_app', or 'no' to cancel: yes
Destroying old test database for alias 'default'...

I receive
__fake__.DoesNotExist: Site matching query does not exist.

>>> from django.contrib.sites.models import Site
>>> Site.objects.all()
<QuerySet [<Site: mysite.ru>]>
>>> Site.objects.first().pk
1

settings.py 
SITE_ID = 1

There is a record in the database, what's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alternativshik, 2019-01-30
@Heavy10110

So the Test database is empty, you must first create an entry in it, and then pull it. The base in dzhanga is cleared after each test.

Y
Yura Khlyan, 2019-01-30
@MAGistr_MTM

I'm not sure, but MB will help First link in Google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question