gis: geo_db_type error in run_checks() in 1.7 (not 1.6)

65 views
Skip to first unread message

dne...@destinati.com

unread,
Jan 25, 2015, 6:04:57 PM1/25/15
to django...@googlegroups.com
Hi,

Wanted to throw this out there, not sure truly if it is my fault or a bug.

Just upgraded from (python 2.6.x, django 1.6) to (python 2.7.x, django 1.7).
If I invoke manage.py on any subcommand, I get an error as follows:

------------
[app_dev]$ python2.7 manage.py sql
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 337, in execute
    self.check()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in check
    all_issues = checks.run_checks(app_configs=app_configs, tags=tags)
  File "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 59, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 1046, in check
    errors.extend(cls._check_fields(**kwargs))
  File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 1122, in _check_fields
    errors.extend(field.check(**kwargs))
  File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py" , line 192, in check
    errors.extend(self._check_backend_specific_checks(**kwargs))
  File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py" , line 290, in _check_backend_specific_checks
    return connection.validation.check_field(self, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py", line 23, in check_field
    field_type = field.db_type(connection)
  File "/usr/local/lib/python2.7/site-packages/django/contrib/gis/db/models/fields.py", line 221, in db_type
    return connection.ops.geo_db_type(self)
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
------------

In mysql/validation.py in Django 1.7 it attempts 'field_type = field.db_type(connection)'. This call isn't made in the same function in Django 1.6, so this problem doesn't arise. If I add this call into the Django 1.6 function the same error appears.

Something to do with the fact that connection.ops is <class 'django.db.DefaultConnectionProxy'>.<class
'django.db.backends.mysql.base.DatabaseOperations'> so it isn't correctly getting to contrib/gis/db/backends/mysql/operations.py (?).

This error occurs for a PointField field (not sure about any others), e.g. a model of the type:

-----------
from django.contrib.gis.db import models class MyModel(models.Model):
    point_xy = models.PointField()
    objects = models.GeoManager()
-----------

CentOS release 6.6 (Final)
geos.x86_64         3.3.2-1.el6
mysql.x86_64            5.1.73-3.el6_5
Django (1.7.3)
Python 2.7.9
MySQL-python (1.2.5)

I fixed this with a hack (avoid the db_type call based on the few field names I use for PointField's), but perhaps this should be looked into.

Dylan Nelson

Collin Anderson

unread,
Jan 27, 2015, 4:01:32 PM1/27/15
to django...@googlegroups.com
Hi,

You could also try the geodjango mailing list if nothing else.

Collin
Reply all
Reply to author
Forward
0 new messages