Multiple values against one variable

I am trying to make a mixin that I have written a little more pythonic, but I have run into a problem.

The original code that works perfectly, is:

    if referring_page == 'register':
        return allow

    elif referring_class == 'EmailVerificationCode':
        return allow

    elif referring_class == 'EmailVerification':
        return allow

    else:
        return redirect('account:verify_email')

Which I changed to:

    if referring_page in {'register', 'EmailVerification', 'EmailVerificationCode'}:
        return allow
    else:
        return redirect('account:verify_email')


Which for some reason doesn’t work, what am I missing?

Your if statements are comparing two different things.

In the first if, you’re checking referring_page when in the second and third cases, you’re comparing referring_class.

Your in comparison however, is only checking referring_page.

What an idiot I am, thank you Ken.

I absolutely reject that statement. You just needed a second pair of eyes.