GeoDjango - Saving client-side GeoJSON in to Model Geometry field

I have a webpage that includes a Leaflet WebMap. In the WebMap a user will be able to draw some polygons. I want to then save these polygons (which will be in the form of GeoJSON) in to my models geom field and then the underlying PostGIS database.

I am aware of the GeoJSON serializer, though from what I have read it sounds like it can’t work the other way - i.e. taking a GeoJSON object and saving it as part of a model save. Is this correct?

If so, are there any other ways I could save GeoJSON as part of a model?

Many thanks

What does your Model look like? (In what field are your storing your polygons?)

Just to close this - I actually worked out that I could use the Django admin in combination with the django-leaflet plugin to end up with a comprehensive Geospatial database editing system. Saved me a tonne of work and undoubtedly, headaches.

Way cool! Glad you’ve got it working for you.

Ken

I have developed a Django application where I’ve integrated a Leaflet map with a polygon drawing tool on the first menu (fields_geometry.html). When a user completes drawing a polygon, a form appears containing fields for the parcel’s name and description. Up to this point, everything is working smoothly without any issues. Now, I want to enhance the functionality so that when the user enters the name and description, the following fields should be stored in the database: name, description, polygon geometry, area, and the ID of the farmer (user) who created the parcel.

To achieve this, I need to make the necessary updates in my Django application so that the relevant information can be correctly stored in the PostGIS database. I’m seeking assistance in analyzing the situation and identifying the changes required.

Since this isn’t directly related to the original post, I’d suggest you open a new topic for this.