Thursday, 15 September 2011

python - How to use Flask-Security register view? -



python - How to use Flask-Security register view? -

has used flask-security extension authentication? how register view work?

http://packages.python.org/flask-security/customizing.html

i referring link above.

@app.route('/register', methods=['get']) def register(): homecoming render_template('security/register_user.html')

i don't want extend default class, want wrap default registration view in site layout did this.

{% extends "layout.html" %} {% block title %}upload{% endblock %} {% block body %} {% "security/_macros.html" import render_field_with_errors, render_field %} {% include "security/_messages.html" %} <h1>register</h1> <form action="{{ url_for_security('register') }}" method="post" name="register_user_form"> {{ 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) }} </form> {% include "security/_menu.html" %} {% endblock %}

and getting next error?

werkzeug.routing.builderror builderror: ('security.register', {}, none)

you don't need create view. default 1 included in flask-security. need enable in flask app config:

app = flask(__name__) app.config['security_registerable'] = true

with this, '/register' route should work. there configuration value alter url if desired:

app.config['security_register_url'] = '/create_account'

other flask-security configuration info can found here: http://pythonhosted.org/flask-security/configuration.html

python flask flask-extensions flask-security

1 comment: