Search code examples
pythondjangodjango-modelsgisgeodjango

I'm using Geodjango to implement a geolocation system for my system but it keeps raising a value error


'''from django.contrib.gis.db import models

class Store(models.Model):

    name = models.CharField(max_length = 100)
    coords= models.PointField()
    store_id = models.IntegerField()'''

Solution

  • Django and Geodjango models must be imported separately.

    One solution is to import django models normally and alias the spatial models import.

    from django.db import models
    from django.contrib.gis.db import models as sp_models
    
    class Store(models.Model):
        name = models.CharField(max_length=100)
        coords = sp_models.PointField()
        store_id = models.IntegerField()