fields.py 448 B

123456789101112131415161718
  1. from wtforms.fields import HiddenField
  2. class CSRFTokenField(HiddenField):
  3. current_token = None
  4. def _value(self):
  5. """
  6. We want to always return the current token on render, regardless of
  7. whether a good or bad token was passed.
  8. """
  9. return self.current_token
  10. def populate_obj(self, *args):
  11. """
  12. Don't populate objects with the CSRF token
  13. """
  14. pass