flask-wtforms

Exact match with filter() Flask

Exact match with filter() Flask Question: I’am new to python and iam coding a small webapp to search in a database. Its fonctionnal but doesnt function well. Example : If i search for a ‘lieu’, a ‘Annee’ and a ‘Signataire’ it doesnt give me the exact matches, instead it gives me every ‘Signataire’ even if …

Total answers: 2

How can I use Flask WTForms and CSRF without session cookie?

How can I use Flask WTForms and CSRF without session cookie? Question: I have a very simple app that has no user management or any Flask-Login auth needs. It has forms, WTForms. All I want to do is collect some data submitted by the form. I could technically disable CSRF validation but Flask WTForms really …

Total answers: 2

Flask Create Form from Dictionary

Flask Create Form from Dictionary Question: Recently started up with Flask. Currently, I have a program that searches through a docx file for {{}} tags and adds them to a dictionary that ends up looking like the below. { ‘{{name}}’:’John’, ‘{{address}}’:’’, ‘{{zip}}:’’ } I would like a page that displays the key field names, and …

Total answers: 2

validate_on_submit() not working in Flask. What should I do?

validate_on_submit() not working in Flask. What should I do? Question: I am new to Flask. The validate_on_submit() is not working and I also don’t know what app.app_context() and app.test_request_context() do in my code. The only thing I am trying to do is get my form to validate I can’t figure out why it’s not working. …

Total answers: 2

Install email_validator using pip

Install email_validator using pip Question: I have email_validator installed but I am getting an error message saying it is not installed. Does it have to be installed in my project folder? Or can it be in the main site-packages folder? When I run my program I get this error message: Exception: Install ’email_validator’ for email …

Total answers: 5

How to handle file upload validations using Flask-Marshmallow?

How to handle file upload validations using Flask-Marshmallow? Question: I’m working with Flask-Marshmallow for validating request and response schemas in Flask app. I was able to do simple validations for request.form and request.args when there are simple fields like Int, Str, Float etc. I have a case where I need to upload a file using …

Total answers: 3

Using uk-postcode-utils in a python form

Using uk-postcode-utils in a python form Question: I am creating a form for the user to enter a valid UK postcode. I currently have the following code for the form: class RegisterForm(Form): first_name = StringField(‘First Name’, validators=[DataRequired(), validators.Length(min=1, max=50)]) last_name = StringField(‘Last Name’, validators=[DataRequired(), validators.Length(min=1, max=50)]) centre_id = StringField(‘Centre ID’, validators=[DataRequired(), validators.Length(min=1, max=11)]) doctor_id = …

Total answers: 1

How to disable csrf for a view with flask-wft for a restapi?

How to disable csrf for a view with flask-wft for a restapi? Question: I get problem for disable csrf using flask-wtf for a restapi. The problem is similar like here: Flask-Restful POST fails due CSRF protection of Flask-WTF, but I use flask original instead of flask-restful. I use the @csrf.exemptdecorator, and I did exactly like …

Total answers: 3

Custom validators in WTForms using Flask

Custom validators in WTForms using Flask Question: I need to make a custom validator in WTForms where the input is to be: number:number – e.g. 2:1 match1 = StringField(‘Russia-Saudi Arabia’, validators=[DataRequired()]) So, my question is – how to create such validator? I’ve looked upon the documentation at http://wtforms.readthedocs.io/en/latest/validators.html, but was not very helpful (for me) …

Total answers: 2

Perform psycopg2 db search based on user input using python function

Perform psycopg2 db search based on user input using python function Question: I’m trying to perform a database search, based on user input. The DBresults function in the below code is intended to catch the input stored in the “ranumber” and perform an SQL search on that specific record. I can’t seem to get this …

Total answers: 1