You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a bit of trouble with this but it could just be me: is it possible to just use only one of these fields to declare a lookup string? Currently we have a non-primary-key field that's used for lookup, but we end up with some weirdness.
Leaving the default lookup_field on our GenericViewset subclass causes any of our "lookup" text to have _pk appended to it, such as foobar_pk
If we update the lookup_field we can get foobar_foobar, but trying to set lookup='' for the router leaves us with _foobar
I see this behavior comes from the very beginning of NestedMixin.__init__... Basically I just want the lookup field to only be foobar with nothing else, is there a way to do that or am I missing something?
The text was updated successfully, but these errors were encountered:
This is an issue that I've faced too -- and I found a sneaky solution for it. In NestedMixin.__init__, I saw that it calls self.nest_prefix = something_somethingelse, so what if we just make that a property that doesn't do anything when assigned, and returns an empty string when retrieved? Well that works, but the __init__ method later validates that self.nest_prefix matches an acceptable regex; by making that blindly return True it all works -- although the return value isn't actually checked.
Any chance this would be integrated in the lib somehow ? Extra param to disable prefix or simply a rule that disable prefix when lookup param is empty ?
Any chance this would be integrated in the lib somehow ? Extra param to disable prefix or simply a rule that disable prefix when lookup param is empty ?
I cannot say that I truly understand the implications of this change. Yet is very possible to be accepted, given that new automated tests do pass along the existing ones in a PR 👍 .
Having a bit of trouble with this but it could just be me: is it possible to just use only one of these fields to declare a lookup string? Currently we have a non-primary-key field that's used for lookup, but we end up with some weirdness.
Leaving the default
lookup_field
on ourGenericViewset
subclass causes any of our "lookup" text to have_pk
appended to it, such asfoobar_pk
If we update the
lookup_field
we can getfoobar_foobar
, but trying to setlookup=''
for the router leaves us with_foobar
I see this behavior comes from the very beginning of
NestedMixin.__init__
... Basically I just want the lookup field to only befoobar
with nothing else, is there a way to do that or am I missing something?The text was updated successfully, but these errors were encountered: