I'm running into a bug when trying to use fixtures with natural keys and
using multiple databases.
If I have two tables A and B, that are routed by a database router to db1
and db2 respectively, then I can load 'regular' fixtures of A in db2.
Django will correctly recognize that A data does not need to be loaded
into db2, and hence give the (correct) output that 0 objects are loaded
from 1 fixture.
However, if I keep everything the same, except that I use natural keys for
the data, then loaddata will give an OperationalError exception.
I've created a minimal reproduction here:
https://github.com/fvkluck/improved-dollop
In its readme I've put the reproduction, the full stacktrace, and explain
where I got my data. Shortest version of the repro is:
1. git clone https://github.com/fvkluck/improved-dollop
2. cd improved-dollop/repro
3. python manage.py migrate
4. python manage.py migrate --database=secondary
5. python manage.py loaddata someprimarymodel_natural.json
--database=secondary
This leads to an exception (OperationalError). Expected is: '0 objects
were loaded from 1 fixture'
Best,
Florian
--
Ticket URL: <https://code.djangoproject.com/ticket/34907>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => abidkhan484
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34907#comment:1>