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

No description provided.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Makes sense for now.

I will take a deeper look later.

Thanks for fixing this.

@ericholscher ericholscher added the PR: hotfix Pull request applied as hotfix to release label Feb 6, 2019
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

Choose a reason for hiding this comment

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

This block could just be:

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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
@delete-merged-branch delete-merged-branch bot deleted the fix-404-500 branch February 6, 2019 20:26
@ericholscher
Copy link
Member Author

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
Labels
PR: hotfix Pull request applied as hotfix to release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants