Custom Lookup: make it work with ForeignFields

24 views
Skip to first unread message

MakersF

unread,
Dec 16, 2015, 5:53:55 AM12/16/15
to Django users
Hi,

For my project I'm using PostgreSQL backend, which supports a really neat feature:

value IN (columnA, columnB, columnC, ...)

I need this feature to be able to query efficiently the DB (I can explain the reason, but I'm not sure it's relevant to this problem now).

I wrote a basic implementation, but it's not working enough for me to use in production

Here is the commented code of the lookup, the table on which it is tested, and the results

https://gist.github.com/MakersF/9ce7002f1ce570e14bc0

What I need for it to be usable on my site:

1) For it to work with ForeignFields
2) To be able to use only() or values()

All the other notes on the code are not really required (but I'm sure they would make development easier. At least the type check)

Looking at the documentation I could not find how to fix the problem with ForeignFields.
Note that I just need to constraint the FFs, I will put them in .defer() as I won't use them, I just care of the rest of the row. I can provide the value of the FF_id.

Looking at the source code of other lookups I couldn't find the solution either.

Can you help me fixing the problem?
Reply all
Reply to author
Forward
0 new messages