Hi Wim,
On 16/07/15 16:51, Wim Feijen wrote:
> Hi,
>
> We are experiencing the same problem when a user changes his language.
> We are using a post form for that, see:
https://roominreturn.nl .
>
> 1. What is annoying is that the csrf Forbidden page is a yellow page and
> is shown to the end user. We would never want to confront a visitor with
> a yellow Forbidden page with techy remarks. Our default 400-page would
> be ok though.
Note that you can avoid the yellow page with the CSRF_FAILURE_VIEW
setting. The view can be as simple as:
def csrf_failure(request, reason=""):
"""
Friendly view for settings.CSRF_FAILURE_VIEW.
"""
return render(request, 'friendly_csrf_failure_template.html',
status=403)
Then in your settings add
CSRF_FAILURE_VIEW = 'path.to.csrf_failure';
Cheers,
Alasdair
[1]:
https://docs.djangoproject.com/en/1.8/ref/settings/#csrf-failure-view
--
Alasdair Nicol
Developer, MEMSET
mail:
alas...@memset.com
web:
http://www.memset.com/
Memset Ltd., registration number 4504980.
Building 87, Dunsfold Park, Stovolds Hill, Cranleigh, Surrey, GU6 8TB, UK