title: User Registration - Flask Security
body: <p>Have been following Flask Security protocols for user registration and login form for flask blog-post type app, using ORM peewee. Login works like a charm though registration is posing issue. 
  Related Question <a href="https://stackoverflow.com/questions/14793098/how-to-use-flask-security-register-view/43685227#43685227">How to use Flask-Security register view?</a></p>
  
  <p>The App:</p>
  
  <pre><code>from flask import render_template, request, redirect, url_for
  from models import *
  @app.route('/')
  def home():
      return render_template('home.html', 
  posts=Post.select().order_by(Post.date.desc()))
  
  @app.route('/login', methods=['GET', 'POST'])
  def login():
      return render_template('/security/login_user.html')
  
  
  @app.route('/register', methods=['GET', 'POST'])
  def register():
      return render_template('/security/register_user.html')
  </code></pre>
  
  <p>Database Handler:</p>
  
  <pre><code>from flask import Flask
  from flask_peewee.db import Database
  from peewee import *
  from flask_security import Security, PeeweeUserDatastore, UserMixin, 
  RoleMixin, login_required
  import datetime
  
  # Create app
  app = Flask(__name__)
  app.config['SECRET_KEY'] = 'super-secret'
  app.config['DATABASE'] = {
      'name': 'unnamed.db',
      'engine': 'peewee.SqliteDatabase',
  }
  app.config['SECURITY_REGISTERABLE'] = True
  app.config['SECURITY_REGISTER_URL'] = '/register'
  app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'security/login_user.html'
  app.config['SECURITY_REGISTER_USER_TEMPLATE'] = 
  'security/register_user.html'
  app.config['SECURITY_RESET_PASSWORD_TEMPLATE'] = 
  'security/reset_password.html'
  app.config['SECURITY_CHANGE_PASSWORD_TEMPLATE'] = 
  'security/change_password.html'
  
  # Database connection object
  db = Database(app)
  
  user_datastore = PeeweeUserDatastore(db, User, Role, UserRoles)
  security = Security(app, user_datastore)
  </code></pre>
  
  <p>Register User Form (The usual Flask_Security file taken from its git):</p>
  
  <pre><code>{% from "security/_macros.html" import render_field_with_errors, 
  render_field %}
  {% include "security/_messages.html" %}
  &lt;h1&gt;{{ ('Register') }}&lt;/h1&gt;
  &lt;form action="{{ url_for_security('register') }}" method="POST" 
  name="register_user_form"&gt;
    {{ register_user_form.hidden_tag() }}
    {{ render_field_with_errors(register_user_form.email) }}
    {{ render_field_with_errors(register_user_form.password) }}
    {% if register_user_form.password_confirm %}
      {{ render_field_with_errors(register_user_form.password_confirm) }}
    {% endif %}
    {{ render_field(register_user_form.submit) }}
  &lt;/form&gt;
  {% include "security/_menu.html" %}
  </code></pre>
  
  <p>The logs show the output during rendering as:</p>
  
  <ul>
  <li>127.0.0.1 - - [28/Apr/2017 22:07:51] "GET /login HTTP/1.1" 200 -</li>
  <li>127.0.0.1 - - [28/Apr/2017 22:07:55] "GET /register/ HTTP/1.1" 404 -</li>
  </ul>
  
  <p>URL with backspace for register is being rendered contrasted against the login. Have checked the whole thing for some hours now, but to no avail. Any hint what might be happening?</p>