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
phatbuck...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to