Python Forum
django-geoposition and unknown column error?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
django-geoposition and unknown column error?
#1
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'
Reply
#2
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/...rview.html
Reply
#3
db_table Naming issues

class Meta:
    managed = False
    db_table = '"building"'
Or maybe...

class Meta:
    managed = False
    fields = ('postal_code','address','latitude','longitude','position')
Reply
#4
(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?

In mysql, I think the column type you'd want is geometry: https://dev.mysql.com/doc/refman/8.0/en/...rview.html

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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python django view error ZeeKolachi 1 317 Mar-18-2024, 03:14 PM
Last Post: Sowmya
Photo After using models.Model on my class Im getting 'ImproperlyConfigured' error Django khavro 1 2,169 Apr-05-2021, 03:11 PM
Last Post: SheeppOSU
  Django : OperationalError no such column: Utilisateurs_videos.user_id Adem 0 3,012 Mar-20-2021, 06:11 PM
Last Post: Adem
  Error - ManyToMany Fields in Django rob25111 0 1,522 Jan-17-2021, 04:58 PM
Last Post: rob25111
  upload big file in Django with process bar and i get error : MemoryError ma_norouzifar 3 4,378 Aug-06-2019, 06:57 AM
Last Post: fishhook
  Django Python Vscode Error Please Help Smhbugra 3 2,700 Jun-30-2019, 10:54 AM
Last Post: noisefloor
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,301 Jun-30-2019, 12:21 AM
Last Post: scidam
  Django Connection Error erfanakbari1 1 2,583 Mar-21-2019, 08:09 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020