How to convert geojson file into class model in django – Code Utility


I have geojson data in the URL. Here is the URL:

I need to generate model class for Django using ogrinspect
from django.contrib.gis.db import models


Step 1: Go to folder level.

Step 2: Make sure django-contrib-gis is installed.

Step 3: Type this command to the terminal python ogrinspect Neighborhoods --srid=4326 --mapping --multi

You will get following result:

class Neighborhoods(models.Model):
pri_neigh = models.CharField(max_length=0)
sec_neigh = models.CharField(max_length=0)
shape_area = models.CharField(max_length=0)
shape_len = models.CharField(max_length=0)
geom = models.MultiPolygonField(srid=4326)

# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models

neighborhoods_mapping = {
'pri_neigh': 'pri_neigh',
'sec_neigh': 'sec_neigh',
'shape_area': 'shape_area',
'shape_len': 'shape_len',