You can dump you database into a fixture and then load that from your test database:
A fixture is a collection of data that Django knows how to import into
a database. The most straightforward way of creating a fixture if
you’ve already got some data is to use the manage.py dumpdata
command
Fixtures can be written as JSON, XML or YAML (with PyYAML installed)
documents.
Loading data is easy: just call manage.py loaddata <fixturename>
,
where is the name of the fixture file you’ve created
And then from SetUp()
in test.py
:
from django.core.management import call_command
call_command("loaddata", "' + 'fixturefile.json' + '",
verbosity=0)
However, in order to keep your test database up to date with your production database (which I wouldn't recommend) you'll have to set up a cron job or something.
Sources:
https://stackoverflow.com/a/48737566/5094841
https://django-testing-docs.readthedocs.io/en/latest/fixtures.html