Form handling in Flask

Now I’m coding simple design-tracking system. Almost looks like a blog service.

I use Flask as web app flame work. But I’m not good at web design. It’s difficult for me to make form template.

There are some extensions about Flask.  And I found that using Flask-Bootstrap( Bootstrap ) make easy to beautiful layout.

Key point was that, wrap form tag with <div class=”form-group tag”> and set “form-control” class in form.field.


{% extends "base.html" %}
{% block content %}
<div class='content container'>
<div class="row">
<div class="col-md-12">
<p>Project Code {{ pj }}</p>
<div class="row">
<div class="col-md-4">

<form role="form" action="/hypothesis/create/", method='post'>
<div class="form-group">
{% for field in form if != "csrf_token" %}
 {{ field.label }}{{ field(class="form-control") }}
{% endfor %}

This code will make following view..

Just tips for me.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s