mardi 29 septembre 2015

SQLite to Django - join tables with same field names

I'm trying to transfer this very simplified query to Django models:

select B.value from A join B on A.id = B.id where B.param = "foo" group by B.value;

Basically giving me unique B.value of rows with common id

My models in Django are:

#A
id = CharField()
...

#B
id = CharField()
param = CharField()
value = CharField()
...

From what I've read, people are against joining tables in Django. How does my query translate to Django in simplest form?

Aucun commentaire:

Enregistrer un commentaire