#25615: multidb Relation fields do not support nested lookups
-------------------------------------+-------------------------------------
     Reporter:  gerdkoetje           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

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


Old description:

> He all,
>
> Does anyone know why i can't do any relation lookups on any database
> other then the default database in 1.8.5 this worked fine in 1.6.1
> it keeps trowing me: Relation fields do not support nested lookups
>
> for example on
> adds =
> ProfielenFlirts.objects.filter(voor__user__profielenuserprofile__fictief=True).filter(Q(antwoord='')
> | Q(antwoord__isnull=True)).count()
>
> ProfielenFlirts is a non default database, the relation lookup is in the
> same database do.
>

> my router
> class DatingRouter(object):
>     def db_for_read(self, model, **hints):
>         if model._meta.app_label == 'datingmodels':
>             return 'dating'
>         return 'default'
>
>     def db_for_write(self, model, **hints):
>         if model._meta.app_label == 'datingmodels':
>             return 'dating'
>         return 'default'
>
>     def allow_relation(self, obj1, obj2, **hints):
>         if obj1._meta.app_label == 'datingmodels' and
> obj2._meta.app_label == 'datingmodels':
>             return True
>         elif 'datingmodels' not in [obj1._meta.app_label,
> obj2._meta.app_label]:
>             return True
>         return False
>
>     def allow_syncdb(self, db, model):
>         if db == 'dating' or model._meta.app_label == "datingmodels":
>             return False # we're not using syncdb on our legacy database
>         else: # but all other models/databases are fine
>             return True
>
> any help would be appriciated

New description:

 Does anyone know why i can't do any relation lookups on any database other
 then the default database in 1.8.5 this worked fine in 1.6.1. It keeps
 telling me: `Relation fields do not support nested lookups`.

 for example on
 `adds =
 
ProfielenFlirts.objects.filter(voor__user__profielenuserprofile__fictief=True).filter(Q(antwoord='')
 | Q(antwoord__isnull=True)).count()`

 ProfielenFlirts is a non default database, the relation lookup is in the
 same database do.


 my router
 {{{
 class DatingRouter(object):
     def db_for_read(self, model, **hints):
         if model._meta.app_label == 'datingmodels':
             return 'dating'
         return 'default'

     def db_for_write(self, model, **hints):
         if model._meta.app_label == 'datingmodels':
             return 'dating'
         return 'default'

     def allow_relation(self, obj1, obj2, **hints):
         if obj1._meta.app_label == 'datingmodels' and obj2._meta.app_label
 == 'datingmodels':
             return True
         elif 'datingmodels' not in [obj1._meta.app_label,
 obj2._meta.app_label]:
             return True
         return False

     def allow_syncdb(self, db, model):
         if db == 'dating' or model._meta.app_label == "datingmodels":
             return False # we're not using syncdb on our legacy database
         else: # but all other models/databases are fine
             return True
 }}}

--

Comment:

 Please provide a minimal sample project that works on 1.6 and fails on
 1.8. The simpler you can make the sample project, the easier it will be to
 determine if it's a bug in your application or in Django. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/25615#comment:3>
Django <https://code.djangoproject.com/>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.702eda1bbf64b785764e47d4b9b0f887%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to