Checking uniqueness contraint during form validation in App Engine

前端 未结 1 618
情话喂你
情话喂你 2021-01-28 17:02

I am using Flask and WTforms in App Engine, trying to implement uniqueness contraint on one of the field. The question is big, please be patient and I have been stuck here from

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 17:47

    Edit: didn't answer your question properly the first time.

    Separate instances of the Form object will be instantiated for the GET and POST requests, so you can't save the old_name to self.

    You'll need to pass the old_name to the browser in the form, and have the browser submit the old_name back in the POST request.

    The easyish way to do this is to create a hidden form field that the user doesn't see, but will get submitted by the POST request. I'm not too familiar with WTForms but I assume you can initialize the old_name field value in your the GET request handler.

    0 讨论(0)
提交回复
热议问题