Flask Admin
Now that we have created the tables in the database, we require a way to manipulate the data within it. It can be done through the terminal but flask provides an admin panel which makes this task easier.
To access the flask admin in the cuba theme, first you need to create an admin account through terminal.
Follow the below given commands to create an admin account
Step 1:
Open the python terminal by typing python3 (if you are a linux user) or
python (if you are a windows user) in the terminal and pressing enter. Make sure that you have
navigated to the cuba folder where the run.py is present.
step 2:
Create an admin account by the below given commandsfrom cuba import db
from cuba.models import User
from werkzeug.security import generate_password_hash
admin = User(email="admin@gmail.com",username="admin",password=generate_password_hash('admin@123',method='sha256'),isAdmin=True)
db.session.add(admin)
db.session.commit()
Make sure you execute commands one by one, and make sure that the paths you have entered are correct one while importing
Step 3:
Now everything is all setup to access our flask admin panel. Navigate to '/admin' after you
base user. If you are in the development server and the server port is default then the link you will
navigate to http://127.0.0.1:5000/admin
This link will redirect you to the login page, now enter the login email and password with which we created the admin account while are:
email: admin@gmail.com
password: Admin@123
Now after logging in you should be able to see the flask admin panel.
If you Don't then access this link again http://127.0.0.1:5000/admin and you will get the access of flask admin panel. Here you can manipulate any data entered inside the database