Opened 9 years ago

Closed 9 years ago

#25615 closed Bug (invalid)

multidb Relation fields do not support nested lookups

Reported by: gerdkoetje Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by gerdkoetje)

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(vooruserprofielenuserprofilefictief=True).filter(Q(antwoord=) | Q(antwoordisnull=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

Change History (13)

comment:1 by gerdkoetje, 9 years ago

Component: UncategorizedDatabase layer (models, ORM)
Type: UncategorizedBug

comment:2 by gerdkoetje, 9 years ago

Summary: multidm Relation fields do not support nested lookupsmultidb Relation fields do not support nested lookups

comment:3 by Tim Graham, 9 years ago

Description: modified (diff)
Resolution: needsinfo
Status: newclosed

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!

comment:4 by gerdkoetje, 9 years ago

Description: modified (diff)

test project proving this issue
https://github.com/gerdkoetje/dualdbtest

comment:5 by gerdkoetje, 9 years ago

Resolution: needsinfo
Status: closednew

comment:6 by Tim Graham, 9 years ago

Resolution: invalid
Status: newclosed

Bisected to 9f13c3328199d2fa70235cdc63bb06b1efc5b117. You are missing 'seconddbapp' in INSTALLED_APPS.

comment:7 by gerdkoetje, 9 years ago

in my main project that is a remote database.
that shouldn't be in installed apps.
so i did the same here.

comment:8 by gerdkoetje, 9 years ago

Resolution: invalid
Status: closednew

comment:10 by Tim Graham, 9 years ago

Resolution: invalid
Status: newclosed

I don't understand your reasoning. You cannot import models from seconddbapp in otherapp if you don't include it in INSTALLED_APPS. Maybe you want to set them as managed=False if those apps aren't managed by the local Django installation. Let's continue the discussion on django-users if you need further help. I don't see any bugs in Django yet.

comment:11 by gerdkoetje, 9 years ago

you don't get my point.
seconde is a remote database in my real project.
and im not able to do reverse lookups on any other db then the default on.
with did work fine in 1.6.1

this is what i did try to prove with this project, only i can't add a remote database to it so i used a locale database for it.

Version 0, edited 9 years ago by gerdkoetje (next)

comment:12 by gerdkoetje, 9 years ago

Resolution: invalid
Status: closednew

comment:13 by Tim Graham, 9 years ago

Resolution: invalid
Status: newclosed

Let's keep this ticket closed until there is a conclusion on django-users that Django is at fault.

Note: See TracTickets for help on using tickets.
Back to Top