django pointfield value format for fixtures 1

django pointfield value format for fixtures

[
    {
    "model": "myapp.Location",
    "pk": 1,
    "fields": {
        "name": "Location Number 1",
        "point": "POINT (30 10)",
    }
  }
]

Here is what the above code is Doing:
1. Create a new Location object
2. Set the name field to “Location Number 1”
3. Set the point field to a Point object with coordinates (30, 10)
4. Save the object to the database
5. Create a dictionary representing the object
6. Add the dictionary to the list of objects
7. Serialize the list of objects using the JSON serializer
8. Output the JSON to the terminal

Similar Posts