jazzband / django-polymorphic

Improved Django model inheritance with automatic downcasting

Home Page:https://django-polymorphic.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fixtures

alvarogf97 opened this issue · comments

Hey there, I have been trying to create objects from a json file with the loaddata command without success. Is there anything special that I need write in the document?

[
  {
    "model": "animals.DogBreed",
    "pk": 1,
    "fields": {
      "polymorphic_ctype": 24,
      "name": { "en": "Affenpinscher", "es": "" },
      "weight": { "bounds": "[)", "lower": "3", "upper": "6" },
      "life_span": { "bounds": "[)", "lower": "10", "upper": "12" },
      "origins": [187, 118],
      "tags": [1, 2, 3, 4, 5, 6]
    }
  }
]

Thanks in advance

Hi @alvarogf97,

I'm also working on serialization. Take a look at #517. When I repeat the steps from my issue, but without the manager code and model method for natural keys, I find that there's no problem. I can replace existing data, or I can change all the IDs from 1 to 2 and it creates a second record.

So that one definitely relates to natural keys, specifically. For your case, try to create a simple model that shows the issue you're having.