![]() |
django-geoposition and unknown column error? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: django-geoposition and unknown column error? (/thread-11097.html) |
django-geoposition and unknown column error? - PrateekG - Jun-22-2018 Hi, I am using django geolocation for showing map with position in my application built on Django2.0.6 + Python3.6 + Mysql. But when I open my form it shows following error- Exception Value: (1054, "Unknown column 'building.position' in 'field list'") Do I need to create a field position in my database? It is not mentioned in the document anywhere. from geoposition.fields import GeopositionField class Building(models.Model): postal_code = models.CharField(max_length=6) address = models.TextField() latitude = models.FloatField(validators=[MinValueValidator(-90.0), MaxValueValidator(90.0)]) longitude = models.FloatField(validators=[MinValueValidator(-180.0), MaxValueValidator(180.0)]) position = GeopositionField() class Meta: managed = False db_table = 'building' RE: django-geoposition and unknown column error? - nilamo - Jun-22-2018 Isn't everything in a model a column in the underlying database? How else would the spacial location be saved? In mysql, I think the column type you'd want is geometry : https://dev.mysql.com/doc/refman/8.0/en/spatial-type-overview.html
RE: django-geoposition and unknown column error? - gontajones - Jun-23-2018 db_table Naming issues class Meta: managed = False db_table = '"building"'Or maybe... class Meta: managed = False fields = ('postal_code','address','latitude','longitude','position') RE: django-geoposition and unknown column error? - PrateekG - Jun-26-2018 (Jun-22-2018, 04:22 PM)nilamo Wrote: Isn't everything in a model a column in the underlying database? How else would the spacial location be saved? Yes, everything in a model is a column in the underlying database. And thanks for sharing the spatial data type, it helps! Sharing my solution what I have done to achieve this- The django-location-filed package does not work properly with django 2.0.6; we need to add position field in database but prior to the 2.0 version it works without adding any new field. So instead of this package I used Google Map Api and with the help of some jquery code I am able to proceed. |