Задать вопрос

Тел: +7 965 3737 888

475

Просмотров

0

Ответов

SSL Redirect Middleware and testing

While we're on the topic of SSLRedirect (See snippet 240 and 880) here's what I add to the end of my ssl middleware module, so that SSLRedirect wont break my automated testing.

It simply creates a dummy middleware class that removes the SSL argument, but does not do any redirecting. If you were to simply remove the middleware from settings, the extra SSL argument will then get passed on to all the relevant views.

Of course, you'll need to define a TESTING variable in settings, or change this to something else like settings.DEBUG. Having the separate variable for testing allows you to run your server in DEBUG mode without side effects like the change above.

Вопрос полезен? Да0/Нет0
file_4374.py(308.0б)
None