Relation fields do not support nested lookups

580 views
Skip to first unread message

probleem support

unread,
Oct 27, 2015, 8:53:20 AM10/27/15
to Django users
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

Tim Graham

unread,
Oct 27, 2015, 9:26:16 AM10/27/15
to Django users
A minimal project that reproduces the error would be helpful. Please avoid duplicating your post on django-users and in Trac (until it's a confirmed bug in Django). Thanks!

probleem support

unread,
Oct 27, 2015, 9:34:20 AM10/27/15
to Django users
sorry for that, ill spend some time on creating a test project with 2 databases on sqlite
But still if anyone is using multidb please confirm to me that this does work in your projects.
Any hints will be appreciated

probleem support

unread,
Oct 27, 2015, 10:55:21 AM10/27/15
to Django users
test project proving my point

Tim Graham

unread,
Oct 27, 2015, 11:35:37 AM10/27/15
to Django users
As noted on the ticket, it looks like you're missing an app in INSTALLED_APPS.
Reply all
Reply to author
Forward
0 new messages