Greetings,
I have an app with a CBV for the main functionality that I'd like to
do some validation on config settings (in settings.py) before carrying
out the view.
My particular view in this case is a FormWizard, but I'd like to know
general to any CBV; what is the correct pattern for doing this? Is
there a standard way to execute validation code upon entering a view
that allows one to access the request object (e.g. for setting
messages) and redirecting clients?
My initial thought was to override __init__() and perform it there but
IIANM it lacks self.request at that point.
What I'd like to implement:
if not settings.SOMEAPP_SETTINGS.get('sender_address'):
messages.error(self.request, "Configuration error:
submission sender address not found. Configure SOMEAPP_SETTINGS in
your project settings file.")
return redirect('index')
--
Darren Spruell
phatb...@gmail.com