Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Testserver fixtures not used

I wanted to start a testserver in Django so that I am able to test my API via Jasmine/FrisbyJs.

For that I found that python3 manage.py testserver would create a test-db and load all the testdata provided in the fixtures, which sound exactly what I need. I am NOT running Django-Testcases ATM.

I created a Fixture called testdata.json and stored it within ./fixtures. I also set up my ./projname/settings.py like that:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Fixture Dir
FIXTURE_DIRS = (
    os.path.join(BASE_DIR, 'fixtures'),
)

I also made sure python3 manage.py loaddata testdata works, which it does:

Installed 1 object(s) from 1 fixture(s)

However, running python3 manage.py testserver testdata.json or python3 manage.py testserver testdata leads to this error:

CommandError: Error: No database fixture specified. Please provide the path of at least one fixture in the command line.

What can I do about this?

like image 916
Gundon Avatar asked Dec 14 '25 12:12

Gundon


1 Answers

python manage.py testserver [Fixture Name]

eg :

python manage.py testserver SampleData

SampleData.json file will be in app/fixture/

like image 113
Pratik Bhatt Avatar answered Dec 16 '25 01:12

Pratik Bhatt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!