Closed Jerome-Celle closed 4 years ago
Hi @farhan0581 or @farhan-cashify can you check my PR? :)
That would be extremely helpful.
For now I'm using an ugly hack that might be help others while the feature is not released.
class OrderUserFilter(AutocompleteFilter):
title = 'User'
field_name = 'user'
rel_model = Order
@property
def parameter_name(self):
return "order__user"
@parameter_name.setter
def parameter_name(self, value):
pass
class OrderLineAdmin(admin.ModelAdmin):
list_filter = (
OrderUserFilter,
)
def lookup_allowed(self, lookup, value):
if lookup == "order__user":
return True
return super().lookup_allowed(lookup, value)
That would be extremely helpful.
Agreed. @seocam, thanks, you just saved me a working day looking for a solution.
sure @seocam this is a really needed feature
I really need this too! Thanks.
sorry guys, was a little occupied, will work on this, thanks for contribution !
Checkout the latest pypi version 0.5
This PR can solve: #27 , #11
This change allow filtering on related field like artiste__record_label, with a Record Label model. I added parameter_name in attribute, so we can set his value before, and it seems enough to allow the filter on related field.
Example: Filter order line with the user that is present on the order