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

Fixed AttributeError when using experiments template tags in your base template #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alesdotio
Copy link

I use {% experiments_confirm_human %} in my base.html template, which is also used for Django error pages. This causes the web process to die with an ugly 500 page instead of the pretty Django one when an error occurs.

Example traceback:

File "..../site-packages/experiments/templatetags/experiments.py", line 23, in experiments_confirm_human
return {'confirmed_human': request.session.get(conf.CONFIRM_HUMAN_SESSION_KEY, False)}
AttributeError: 'NoneType' object has no attribute 'session'

The template tag should probably not be used on error pages in the first place, but we can prevent it from failing by checking if the request is None.

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

Successfully merging this pull request may close these issues.

1 participant