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

Be more defensive in our 404 handler #5243

Merged
merged 1 commit into from Feb 6, 2019
Merged

Be more defensive in our 404 handler #5243

merged 1 commit into from Feb 6, 2019

Conversation

@ericholscher
Copy link
Member

@ericholscher ericholscher commented Feb 6, 2019

No description provided.

humitos
humitos approved these changes Feb 6, 2019
Copy link
Member

@humitos humitos left a comment

Makes sense for now.

I will take a deeper look later.

Thanks for fixing this.

version = project.versions.get(slug=version_slug)
version_qs = project.versions.filter(slug=version_slug)
if version_qs.exists():
version = version_qs.first()
Copy link
Contributor

@davidfischer davidfischer Feb 6, 2019

This block could just be:

version = project.versions.filter(slug=version_slug).first()

Copy link
Contributor

@davidfischer davidfischer Feb 6, 2019

Returns the first object matched by the queryset, or None if there is no matching object. 

https://docs.djangoproject.com/en/1.11/ref/models/querysets/#first

@ericholscher ericholscher merged commit a472cb9 into master Feb 6, 2019
1 of 2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the fix-404-500 branch Feb 6, 2019
@ericholscher
Copy link
Member Author

@ericholscher ericholscher commented Feb 6, 2019

Merging this because I already hotfixed it, will update in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants