Sunday, January 25, 2015

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

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c59ff7b3-de78-474e-a024-3d258e1ef648%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment