-1

I have a problem, when i call request.method, it has value get, although in form, i use post method. Please help me thank you!

my controller

def status_sj():
    o = OdooUtility()
    form = SearchForm()
    controls = None
    if request.method == 'POST':
        controls = "oke"
    return render_template('order_entry_v2/status_sj.html', control=controls, form=form)

view html

    <form method=" POST">
            <div class="container-fluid row pull-12">
                <div class="col-sm-12">
                    <div class="col-sm-4" style="margin: 0.2px; padding: 0.2px;">
                        {{ form.month(class_ = 'form-control') }}
                </div>
                <div class="col-sm-4" style="margin: 0.2px; padding: 0.2px;">
                    {{ form.year(class_ = 'form-control') }}
                </div>
                <div class="col-sm-2" style="margin: 0.2px; padding: 0.2px;">
                    <button type="submit" class="btn btn-primary">Cari</button>
                </div>    
                </div>
            </div>
        </form>
davidism
  • 121,510
  • 29
  • 395
  • 339
yudha
  • 9
  • 2

1 Answers1

0

it seems, you are missing POST in methods list in the decorator above your view function

@app.route('/', methods=['GET', 'POST'])
def status_sj():
    [..]
cizario
  • 3,995
  • 3
  • 13
  • 27