0

I have a Flask-Admin project set up with Flask-Security as well. It is pretty much https://pythonhosted.org/Flask-Security/quickstart.html#id1 but just more advanced. I can access the login page at localhost/login and logout and localhost/logout. The logging in and logging out works.

The templates for Flask-Admin works and everything is displayed as I'd expect. However, there are no templates on my machine or docker container where the Flask-Admin app is run. I installed Flask by running pip install Flask-Admin. I know I can over ride the security log in by adding something like

SECURITY_LOGIN_USER_TEMPLATE = 'security/login_user.html'

to the config file and uploading to /templates/security/login_user.html. There is also using

{%extends base.html} 

to have a common theme. Should I have template files already in my project?

1 Answers1

0

Flask Security have a default login template, if you want to use your own template for login or register follow these steps:

  1. Create in template folder the a subfolder named security
  2. Add your html documents to this folder
  3. Go to your flask configuration and add the following settings:

    If your want the register functionality

    SECURITY_REGISTERABLE = True

    Add the name of your templates:

    SECURITY_LOGIN_USER_TEMPLATE = 'security/login.html'

    SECURITY_REGISTER_USER_TEMPLATE = 'security/register.html'

Remember to use the appropriate form in login.html and in register.html, usually causes doubts but is simple:

register.html: register_user_form.field

login.html: login_user_form.field

These are the configurations for this work correctly.

this repository can you to see and understand better doubt:

Carlos Azuaje
  • 109
  • 3
  • 13