Skip to content

Commit

Permalink
Merge pull request #2563 from ElLorans/master
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams authored Nov 4, 2024
2 parents f92d283 + c7c1aac commit 1cdd355
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions doc/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,13 @@ This targets SQLAlchemy specifically.
Unlike the previous setting, this will specifically only affect the behaviour of
IntegrityErrors. These usually come from violations on constraints in the database,
for example trying to insert a row with a primary key that already exists.

Adding a favicon to the admin page
************************************
Adding a favicon to flask-admin is easy: just save a .ico file and add a /favicon.ico
route to your flask app.

from flask import redirect, url_for
@app.route("/favicon.ico")
def favicon():
return redirect(url_for("static", filename="favicon.ico"))
5 changes: 3 additions & 2 deletions examples/sqla/admin/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import flask_admin as admin
from flask import send_file
from flask import redirect
from flask import url_for
from flask_admin.babel import gettext
from flask_admin.base import MenuLink
from flask_admin.contrib import sqla
Expand Down Expand Up @@ -42,7 +43,7 @@ def index():

@app.route("/favicon.ico")
def favicon():
return send_file("static/favicon.ico")
return redirect(url_for("static", filename="/favicon.ico"))


# Custom filter class
Expand Down

0 comments on commit 1cdd355

Please sign in to comment.