Django fixtures many to many with natural keys over multiple fields

545 Views Asked by At

I'm writing some additional fixtures for a project, and I have a question about how to use the natural keys.

In another fixture, the natural key for area is defined like so:

"fields": {
            "area": [
                "auckland",
                "NZ"
            ],

However, I'm writing a fixture for a model with a ManyToMany relation, so how do I include multiple two object keys? the following doesn't seem to work.

"fields": {
            "areas": [
                "auckland",
                "NZ",
                "sydney",
                "AUS"
            ],
1

There are 1 best solutions below

0
Darkstarone On BEST ANSWER

Ok, turns out its super straightforward:

"fields": {
            "areas": [
                [
                    "auckland",
                    "NZ",
                ],
                [
                    "sydney",
                    "AUS"
                ]
            ],