feat: Add custom get user queryset method (fixes #903)#961
feat: Add custom get user queryset method (fixes #903)#961Andrew-Chen-Wang wants to merge 2 commits intojazzband:masterfrom
Conversation
for more information, see https://pre-commit.ci
| } | ||
| ) | ||
|
|
||
| def get_user_queryset(self, user_id: Any = None) -> AuthUser | None: |
There was a problem hiding this comment.
it's a bit nitty, but would the better method name here be get_user_object?
It would immediately be clear from the name that an object is fetched, and not a queryset, and it would be similar to DRF method: https://www.django-rest-framework.org/api-guide/generic-views/#get_objectself
| user = self.get_user_queryset(user_id) | ||
| if not user: |
There was a problem hiding this comment.
DRF has a get_object method but they never check if really only one object is returned from the method, so i guess we shouldn't too. Just wanted to raise this so that we are aware of this problem if someone does a filter instead of get in get_user_queryset
There was a problem hiding this comment.
We should be ensuring that only a single object is returned, otherwise we can raise a dev internal error for multiple objects returned or an iterable is returned as a helpful guide.
fixes #903