Solved: django pointfield value format for fixtures

The main problem is that it’s not possible to specify a custom pointfield format for fixtures.

I am trying to load a fixture in Django that has a PointField. The value is stored in the database as:
<code>SRID=4326;POINT(1.23456789 1.23456789)
The fixture file looks like this:
<code>[{'model': 'myapp.MyModel', 'pk': 1, 'fields': {'point': SRID=4326;POINT(1.23456789 1.23456789)}},]
However, I get the following error when I try to load it: 
<p>django.core.serializers.base.DeserializationError: Problem installing fixture '/path/to/fixture/file': Could not load myapp_mymodel(1): (point_field) invalid input syntax for type geometry</p>


 Django fixtures are in JSON format, so you need to use <code>"SRID=4326;POINT(1.23456789 1.23456789)"</code>.  Also, you need to use <code>"point"</code>, not <code>"Point"</code>.  This should work:  

    [{'model': 'myapp_mymodel', 'pk': 1, 'fields': {'point': "SRID=4326;POINT(1 23)"}}]


A pointfile is a data structure used in the Django web framework to store information about a website. A pointfile contains information about a single website, such as the URL, the name of the domain, and other metadata.

Values format in Django

The Values format in Django is a way to define a set of values that your project will adhere to. This can be used to document your project’s philosophy, or to help you make decisions about how your project should be run.

To use the Values format in Django, first create a module called values . In this module, you’ll define all of the values that your project will adhere to. You can put any documentation you want in this module, but for now, just give it the following contents:

from django.conf import settings from import call_command from django.utils import timezone def main (): # Set some global settings. settings . SETTINGS_MODULE = “values” # Define the values that this project follows. myvalues = { ‘code of conduct’ : ‘We are committed to providing a harassment-free experience for everyone.’ , } call_command ( “echo %s > /etc/hosts” % myvalues [ ‘code of conduct’ ], timezone = timezone . now ()) if __name__ == “__main__” : main ()

What is fixtures

Fixtures are a way of storing data in a database that can be used by Django applications. They allow you to define specific values for fields in a database table, and then use those values when you create instances of the model object.

Related posts:

Leave a Comment