Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2019 - Update 'MultiUsernameField' to handle display names #6351

Merged

Conversation

smithellis
Copy link
Contributor

No description provided.

except User.DoesNotExist:
msg = _("{username} is not a valid username.")
try:
Copy link
Collaborator

Choose a reason for hiding this comment

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

In order to avoid the nesting of the try/except clause you could use something like:

user = User.objects.filter(Q(username=username) | Q(profile__name=username).first()
Copy link
Collaborator

@akatsoulas akatsoulas left a comment

Choose a reason for hiding this comment

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

Looks good! Please squash the 2 commits before merging.

Use Q for improved query
Fix issue where an invalid username forces full revision list
@smithellis smithellis force-pushed the 2019-filter-username-or-displayname-update branch from 4d8b213 to 76db052 Compare November 18, 2024 18:34
@smithellis smithellis merged commit c760798 into mozilla:main Nov 18, 2024
2 checks passed
@smithellis smithellis deleted the 2019-filter-username-or-displayname-update branch November 18, 2024 20:32
@smithellis smithellis restored the 2019-filter-username-or-displayname-update branch November 20, 2024 13:08
smithellis added a commit to smithellis/kitsune that referenced this pull request Dec 19, 2024
)

Use Q for improved query
Fix issue where an invalid username forces full revision list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants