Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/application/serializers/application_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_query_set(self, select_ids=None):
if 'abstract' in self.data and self.data.get('abstract') is not None:
base_query_dict['application_chat.abstract__icontains'] = self.data.get('abstract')
if 'username' in self.data and self.data.get('username') is not None:
base_query_dict['application_chat.asker__username'] = self.data.get('username')
base_query_dict['application_chat.asker__username__icontains'] = self.data.get('username')


if select_ids is not None and len(select_ids) > 0:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there are no irregularities or potential issues with the code provided. The only change to note is that asker__username should be converted to asker__username__icontains. This ensures that all usernames starting with the given username query will match when using an ICONTAINS lookup, which allows partial text matches.

The changes:

             # Old line (without iexact)
-            base_query_dict['application_chat.asker__username'] = self.data.get('username')

             # New line with iexact
+            base_query_dict['application_chat.asker__username__icontains'] = self.data.get('username')

This makes sure the filter works as expected for both exact and partial matches of the username field.

Expand Down
Loading