Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
module 'werkzeug.wrappers.request' has no attribute 'form' Error for Flask project

The question here might be repeated, but I was not able to get a solution from any material available online. I am trying to get the value of the Selected Dropdown list as a string, So that later based on the selected item I can select the type of plot to be displayed. But I'm getting a 'form' error.

HTML code of the form:

        <form action="{{ url_for('visualize') }}" method="GET">
            Select one from the given options:

            <select name="plots">
                <option value="{{Selected_plot[0]}}" selected>{{Selected_plot[0]}}</option>
                {% for plots in Selected_plot[1:] %}
                <option value="{{plots}}">{{plots}}</option>
                {% endfor %}
            </select>
            <input type="submit" value="Submit" />
        </form>

python code :

@app.route('/')
def home():
    Selected_plot = ['Scatter plot', 'Line Plot','Box Plot']
    return render_template('homepage.html' )


@app.route('/visualize', methods=['POST', 'GET'] )
def visualize():
    """Renders the contact page."""
    if request.method == "GET":
        plot_selected = str(request.form['plots'])

    if plot_selected ==  'Scatter plot':
        #Scatter plot code 
    elif plot_selected ==  'Line Plot':
        # Line plot code
    else:
        # Box plot code 

Thanks to the Community in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try

request.values.get("plots", <default_value>)

Note: <default_value> is whatever you wish to be the value if the program can't find the variable "plots". You can skip it if you're sure you'll always send the variable, plots.

The advantage of this format (request.values.get) is that it will work with both POST & GET (i.e. forms data passed through a POST/form-body or just query string)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda