5π
There is actually a bug in Django that causes it to ignore the name-based db-specific pointers if you specify the entire fixture name.
so if you do fixtures = ["mydata.default.yaml", "mydata.myotherdatabase.yaml"]
It will load both fixtures into the default database.
But if you do fixtures = ['mydata']
It will load correctly. This is also true for dbengine specific filenames (e.g. mydata.default.postgresql.sql
) as well.
2π
Fixtures are targeted at specific databases by filename. This is true in TestCase instances as well, as they just call the loaddata command.
See https://docs.djangoproject.com/en/dev/ref/django-admin/#database-specific-fixtures
- Has_permission() missing 1 required positional argument: 'view'
- You have 3 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth
- Django Postgres ArrayField vs One-to-Many relationship
- How can I change the URL to the Django admin interface?
- How can I determine if instance of class from Django model is subclass of another model?
0π
If you have a multi-db setup with models exclusive to each database. You need to save a fixture file for each database (with the non-applicable database files being empty).
If your code defines fixtures = ["sample"]
and you have two databases default
and other
.
You need two files: sample.default.json
and sample.other.json
. If sample
contains only models from db default
, sample.other.json
will be an empty file ([]
) and vice-versa.
Tried with Django 3.2
- How to emit SocketIO event on the serverside
- In Django ORM, "values" and "annotate" are not working to group by
- Django saving json value to database/model
- Django model inheritance and type check