Closed SafaAlfulaij closed 1 year ago
Well, first of all I would have to rename the project as properties don't take parameters by definition. 😄
Seriously though, I don't really know what that would actually look like. The whole extension is built around the idea of using properties the same way as Django's fields - on both the object level as well as the queryset level. This only really works because both fields and properties cannot be accessed with arguments.
For example, both fields and queryable properties can be used to filter a queryset like
MyModel.objects.filter(my_property='some_value')
I'm not sure how to get arguments for the property in there in a way that's convenient and intuitive. If you have any suggestions, let me know.
:)
I forgot to mention that what I'm thinking about is annotations only, and not filterable or updatable properties, as it might not make sense there.
The thing is, those features aren't completely unrelated - an annotatable property can be used for filtering implicitly. Completely separating annotations from filters would essentially remove features and make writing properties harder, which is why I wouldn't really want to do that. Also, queryable properties are currently designed to be usable in all scenarios (depending on what exactly gets implemented with a specific property, of course) and IMO it would be way cleaner to keep this design philosophy and not have properties that can only be used in certain circumstances.
So for me, the problem described above would have to be solved in order to implement something like this properly.
Sometimes I find myself needing to pass the user to the property to filter based on his access, etc. I know that properties doesn't accept arguments. Django provides methods to models and querysets. What if we can have the same with properties to methods?