[Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-21 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
   Reporter:  EDWIN  |  Owner:  nobody
  CUBILLOS   |
   Type:  Bug| Status:  new
  Component:  Database   |Version:  1.11
  layer (models, ORM)|   Keywords:  postgis, mysql,
   Severity:  Normal |  multidatabase
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 **models**
 {{{
 from django.contrib.gis.db import models

 class Ciudad(models.Model):
 nombre = models.CharField(max_length=50, blank=True, null=True,
 unique=True)
 departamento = models.CharField(max_length=80, blank=True, null=True,
 unique=True)
 punto = models.PointField(blank=True, null=True)
 polygon = models.PolygonField(blank=True, null=True)
 precio_base = models.TextField(blank=True, null=True)
 precio_yamimo = models.TextField(blank=True, null=True)


 class Zona(models.Model):
 nombre = models.CharField(max_length=50, blank=True, null=True,
 unique=True)
 polygon = models.PolygonField(blank=True, null=True)
 ciudad = models.ForeignKey(Ciudad, blank=True, null=True)
 recargo = models.IntegerField(default=0, blank=True, null=True)
 }}}


 **settings**

 {{{
 INSTALLED_APPS = [
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.contrib.gis',
 'compressor',
 'django_extensions',

 'djcelery',
 'django_crontab',

 'ciudades',
 'api',

 ]

 DATABASES = {
 'default': {
 'ENGINE': 'django.db.backends.mysql',
 'NAME': 'db_1',
 'USER': 'root',
 'PASSWORD': '',
 'HOST': '127.0.0.1',
 'PORT': '3306',
 },
 'celery': {
 'ENGINE': 'django.db.backends.mysql',
 'NAME': 'db_cel',
 'USER': 'root',
 'PASSWORD': '',
 'HOST': '127.0.0.1',
 'PORT': '3306',
 },
 'geozone': {
 'ENGINE': 'django.contrib.gis.db.backends.postgis',
 'NAME': 'db_post',
 'USER': 'root',
 # 'PASSWORD': '',
 'HOST': '127.0.0.1',
 'PORT': '5432',
 }

 }

 DATABASE_ROUTERS = ['api.router.AutoRouter']

 DB_APPS_MAPPING ={
 "ciudades" : "geozone",
 "django"  : "celery",
 "djcelery" : "celery"
  }
 }}}

 **Router**

 {{{
 from settings import DB_APPS_MAPPING

 ## class for router app with db
 class AutoRouter(object):

 def db_for_read(self, model, **hints):
 # if app_label is not in maps is default db (None
 return DB_APPS_MAPPING.get(model._meta.app_label)

 def db_for_write(self, model, **hints):
 return DB_APPS_MAPPING.get(model._meta.app_label)

 def allow_relation(self, obj1, obj2, **hints):
 app1_db = DB_APPS_MAPPING.get(obj1._meta.app_label)
 app2_db =  DB_APPS_MAPPING.get(obj2._meta.app_label)
 return True if app1_db == app2_db else None

 def allow_migrate(self, db, app_label, model_name=None, **hints):
 return DB_APPS_MAPPING.get(app_label)
 }}}

 **ERROR**
 {{{
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/core/checks/registry.py", line 81, in run_checks
 new_errors = check(app_configs=app_configs)
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/core/checks/model_checks.py", line 30, in check_all_models
 errors.extend(model.check(**kwargs))
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/db/models/base.py", line 1283, in check
 errors.extend(cls._check_fields(**kwargs))
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/db/models/base.py", line 1358, in _check_fields
 errors.extend(field.check(**kwargs))
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/db/models/fields/__init__.py", line 219, in check
 errors.extend(self._check_backend_specific_checks(**kwargs))
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/db/models/fields/__init__.py", line 322, in
 _check_backend_specific_checks
 return connections[db].validation.check_field(self, **kwargs)
   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
 packages/django/db/backends/mysql/validation.py", line 49, in check_field
 field_type = field.db_type(self.connection)
   File "/Users/c02stf74fvh3/.virtu

Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-21 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham):

 This looks similar to #28499. Can you confirm that you're using Django
 1.11?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.4f6d80ccc89b9e10c3bfd5c58f144f57%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-21 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Old description:

> **models**
> {{{
> from django.contrib.gis.db import models
>
> class Ciudad(models.Model):
> nombre = models.CharField(max_length=50, blank=True, null=True,
> unique=True)
> departamento = models.CharField(max_length=80, blank=True, null=True,
> unique=True)
> punto = models.PointField(blank=True, null=True)
> polygon = models.PolygonField(blank=True, null=True)
> precio_base = models.TextField(blank=True, null=True)
> precio_yamimo = models.TextField(blank=True, null=True)
>

> class Zona(models.Model):
> nombre = models.CharField(max_length=50, blank=True, null=True,
> unique=True)
> polygon = models.PolygonField(blank=True, null=True)
> ciudad = models.ForeignKey(Ciudad, blank=True, null=True)
> recargo = models.IntegerField(default=0, blank=True, null=True)
> }}}
>

> **settings**
>
> {{{
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.humanize',
> 'django.contrib.gis',
> 'compressor',
> 'django_extensions',
>
> 'djcelery',
> 'django_crontab',
>
> 'ciudades',
> 'api',
>
> ]
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'db_1',
> 'USER': 'root',
> 'PASSWORD': '',
> 'HOST': '127.0.0.1',
> 'PORT': '3306',
> },
> 'celery': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'db_cel',
> 'USER': 'root',
> 'PASSWORD': '',
> 'HOST': '127.0.0.1',
> 'PORT': '3306',
> },
> 'geozone': {
> 'ENGINE': 'django.contrib.gis.db.backends.postgis',
> 'NAME': 'db_post',
> 'USER': 'root',
> # 'PASSWORD': '',
> 'HOST': '127.0.0.1',
> 'PORT': '5432',
> }
>
> }
>
> DATABASE_ROUTERS = ['api.router.AutoRouter']
>
> DB_APPS_MAPPING ={
> "ciudades" : "geozone",
> "django"  : "celery",
> "djcelery" : "celery"
>  }
> }}}
>
> **Router**
>
> {{{
> from settings import DB_APPS_MAPPING
>
> ## class for router app with db
> class AutoRouter(object):
>
> def db_for_read(self, model, **hints):
> # if app_label is not in maps is default db (None
> return DB_APPS_MAPPING.get(model._meta.app_label)
>
> def db_for_write(self, model, **hints):
> return DB_APPS_MAPPING.get(model._meta.app_label)
>
> def allow_relation(self, obj1, obj2, **hints):
> app1_db = DB_APPS_MAPPING.get(obj1._meta.app_label)
> app2_db =  DB_APPS_MAPPING.get(obj2._meta.app_label)
> return True if app1_db == app2_db else None
>
> def allow_migrate(self, db, app_label, model_name=None, **hints):
> return DB_APPS_MAPPING.get(app_label)
> }}}
>
> **ERROR**
> {{{
>   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
> packages/django/core/checks/registry.py", line 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
> packages/django/core/checks/model_checks.py", line 30, in
> check_all_models
> errors.extend(model.check(**kwargs))
>   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
> packages/django/db/models/base.py", line 1283, in check
> errors.extend(cls._check_fields(**kwargs))
>   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
> packages/django/db/models/base.py", line 1358, in _check_fields
> errors.extend(field.check(**kwargs))
>   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
> packages/django/db/models/fields/__init__.py", line 219, in check
> errors.extend(self._check_backend_specific_checks(**kwargs))
>   File "/Users/c02stf74fvh3/.virtualenvs/Rapigo/lib/python2.7/site-
> packages/django/db/models/fields/__init__.py", line 322, in
> _check_backend_specific_checks
> return connections[db].validation.check_field(self, **kwargs)
>   File "/Users/c02stf74fvh3/.virtualenvs/

Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-22 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 I don't see anything that suggests a bug in Django. Maybe you need to
 modify your router's `allow_migrate()` method as you suggested in the
 description. Please see TicketClosingReasons/UseSupportChannels for ways
 to get help debugging your code and reopen the ticket if you confirm a bug
 in Django.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.905cdbf72f40912b4a4f70a747c68881%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-22 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by EDWIN CUBILLOS):

 I believe that you don't understand my suggest ,
 i don't suggest modify my router method
 i suggest modify the **allow_migrate()** method in **django/db/utils.py**

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.354fcae50028e35eb4c768507706c35a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-22 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham):

 Correct, I don't see the reason why we'd add those lines to Django.
 `settings.DB_APPS_MAPPING` is something you've added, it's not an existing
 setting in Django and I don't see a reason to add it.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.68740cf8aa48df0c2c6710a007276c96%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-22 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Shai Berger):

 Hi Edwin,

 To expand Tim's comment: Your router's `allow_migrate()` should return a
 Boolean. Instead, it returns the app's database-name (from your
 `DB_APPS_MAPPING`), which, for every app actually defined there, is
 truthy.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.cf8a1b5b397209622eba26a5e5fef584%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28515: mysql is checking all models also models that are mapped to POSTGIS

2017-08-22 Thread Django
#28515: mysql is checking all models also  models that are mapped to POSTGIS
-+-
 Reporter:  EDWIN CUBILLOS   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  postgis, mysql,  | Triage Stage:
  multidatabase  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by EDWIN CUBILLOS):

 oh , thanks
 **Shai Berger**
 that it is the answer,

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.3c109b9a02b428473c2c30c84a20ca98%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.