Backward query is not working with GEO Manager

9 views
Skip to first unread message

aarti sawant

unread,
Apr 14, 2015, 6:05:09 AM4/14/15
to django...@googlegroups.com
I am using Geomanager for storing MultiPolygon data.
I have below tables:
il
class Customer(gismodels.Model):
    is_active = models.CharField(max_length=15, default="Inactive", choices= ACTIVE_CHOICES)
    name = models.CharField(max_length=255)
    organisation_name = models.CharField(max_length=100, blank = True)
    rating = models.CharField(max_length=25,choices=RATING_CHOICES,null=True, blank=True)
    description = models.TextField(max_length=255, blank=True)
    email_primary = models.EmailField(max_length=1000 ,null=False, default="tes...@gmail.com")
    email_secondary = models.EmailField(max_length=1000 ,null=True, blank=True)
    phone_primary = models.CharField(max_length=1000)
    phone_secondary = models.CharField(max_length=1000, null=True, blank=True)
    address = models.CharField(max_length=2000, blank=True)
    has_shop = models.CharField(max_length=128, verbose_name="Does he have a shop?", choices=[('Yes', 'Yes'),('No', 'No')],blank=True)
    working_hours_start = models.CharField(max_length=12,blank=True,verbose_name="What is the 
    website = models.URLField(blank=True, null=True)
    expertise = models.CharField(max_length=2000, blank=True)
    experience = models.CharField(max_length=12, null=True, blank=True)
    city = models.ForeignKey(City, null=True)
    country = models.CharField(max_length=255,choices=COUNTRY_CHOICES,null=True, blank=True)
    multi_poly = gismodels.MultiPolygonField(srid=4326, null=True, blank=True,verbose_name="Service Locations")
    objects = gismodels.GeoManager()
    
    class Meta:
        db_table = 'customer'
        verbose_name = 'Customer'
        verbose_name_plural = 'Customers'


class Logs(models.Model)
    '''logs Info'''
    merchant = models.ForeignKey(Merchant, verbose_name='Merchant')
    message = models.TextField(max_length=255, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

So from shell when i try to access merchant from logs object i get error
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 572, in __get__
    rel_obj = qs.get()
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/query.py", line 351, in get
    num = len(clone)
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/query.py", line 122, in __len__
    self._fetch_all()
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/query.py", line 966, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/query.py", line 265, in iterator
    for row in compiler.results_iter():
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/web/Search/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 128, in execute
    return self.cursor.execute(query, args)
  File "/home/web/Search/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/web/Search/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'customer.city_id' in 'field list'")

Reply all
Reply to author
Forward
0 new messages