On Thursday, March 21, 2013 5:07:36 PM UTC-4, aub...@deepearth.co.uk wrote:
Hello,
I have form class that has a relatively lengthy clean method which does field
validation (as the validity of fields depends on the values of fields) as well
setting error messages on the form itself. I also intend to be part of an app
used in multiple views in a few projects.
I want to run certain actions (aside from the usual slew of validation failure
messages) based upon 1) the view in the which the form is being used 2) which
clean checks fail. These actions may also need to alter the http response,
possibly adding items to the context of the template to be rendered and
possibly changing which template to use all together.
I'm relatively new to the Django framework and I was wandering if anyone had
ideas what might a good way to go about this.
Below are current thoughts on the problem:
+ Have the validation function set variables on the form when validation
checks fail and use these in the view to determine what action to run. The
problem with this is would mean subclassing existing Django classes and
altering them to set attributes when the built in validation checks fail.
I believe you can just set self.my_flag = foo in clean method and then check for
that. -ak
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+unsubscribe@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment