Skip to content
Advertisement

Django-queryset join without foreignkey

model.py

JavaScript

What I want is to get id_noga where dzienrok=1234. I know that dziens should be

JavaScript

but it isn’t and I can’t change that. Normally I would use something like

JavaScript

but I don’t know how to join and filter those tables without foreignkey.

Advertisement

Answer

It’s possible to join two tables by performing a raw sql query. But for this case it’s quite nasty, so I recommend you to rewrite your models.py.

You can check how to do this here

It would be something like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement