Django. Restrict page access

303 Views Asked by At

I have some custom error pages and views for them. How can I restrict access to this pages from browser directly, so if user type in address string "somesite/some_error" he won't get this page. It should be showed only when some error occurred.

1

There are 1 best solutions below

0
On BEST ANSWER

Instead of prohibiting access, can't you simple render the error page you want to display? That is, instead of the

render_to_result('mypage.html', {})

you do now, do a

render_to_result('error500.html', {'error': 'oops'})

That way you don't have explicit urls, but you do get the information out to the user.