Flask-admin: How to change /admin url?

Created on 16 Sep 2016  路  4Comments  路  Source: flask-admin/flask-admin

How to change /admin root url?

Use Admin like below?

   admin = admin.Admin(app,
                        'JTY Admin',
                        index_view=AdminIndexView(), 
                        url='/admin_test')

Most helpful comment

after change url, It makes me unable to get the static file:
admin = Admin( url="/flask-admin", endpoint="flask-admin")

and all the static file called 404:

::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /flask-admin/ HTTP/1.1" 200 3286 0.067617 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/swatch/default/bootstrap.min.css?v=2.3.2 HTTP/1.1" 404 342 0.004343 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/css/bootstrap-responsive.css?v=2.3.2 HTTP/1.1" 404 342 0.001147 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/admin/css/bootstrap2/admin.css?v=1.1.1 HTTP/1.1" 404 342 0.001148 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2 HTTP/1.1" 404 342 0.001229 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/select2/select2.min.js?v=3.5.2 HTTP/1.1" 404 342 0.001615 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/moment.min.js?v=2.9.0 HTTP/1.1" 404 342 0.005141 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/jquery.min.js?v=2.1.4 HTTP/1.1" 404 342 0.004514 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/jquery.min.js?v=2.1.4 HTTP/1.1" 404 342 0.001098 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2 HTTP/1.1" 404 342 0.001109 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/moment.min.js?v=2.9.0 HTTP/1.1" 404 342 0.001314 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/select2/select2.min.js?v=3.5.2 HTTP/1.1" 404 342 0.003048

how to fix it?

All 4 comments

You pass url argument, like in your example. See here: https://github.com/flask-admin/flask-admin/blob/master/flask_admin/base.py#L415

after change url, It makes me unable to get the static file:
admin = Admin( url="/flask-admin", endpoint="flask-admin")

and all the static file called 404:

::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /flask-admin/ HTTP/1.1" 200 3286 0.067617 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/swatch/default/bootstrap.min.css?v=2.3.2 HTTP/1.1" 404 342 0.004343 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/css/bootstrap-responsive.css?v=2.3.2 HTTP/1.1" 404 342 0.001147 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/admin/css/bootstrap2/admin.css?v=1.1.1 HTTP/1.1" 404 342 0.001148 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2 HTTP/1.1" 404 342 0.001229 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/select2/select2.min.js?v=3.5.2 HTTP/1.1" 404 342 0.001615 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/moment.min.js?v=2.9.0 HTTP/1.1" 404 342 0.005141 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/jquery.min.js?v=2.1.4 HTTP/1.1" 404 342 0.004514 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/jquery.min.js?v=2.1.4 HTTP/1.1" 404 342 0.001098 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2 HTTP/1.1" 404 342 0.001109 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/moment.min.js?v=2.9.0 HTTP/1.1" 404 342 0.001314 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/select2/select2.min.js?v=3.5.2 HTTP/1.1" 404 342 0.003048

how to fix it?

I remember there is a decorator named expose, could you use this to redefine your new url.

after change url, It makes me unable to get the static file:
admin = Admin( url="/flask-admin", endpoint="flask-admin")

and all the static file called 404:

::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /flask-admin/ HTTP/1.1" 200 3286 0.067617 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/swatch/default/bootstrap.min.css?v=2.3.2 HTTP/1.1" 404 342 0.004343 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/css/bootstrap-responsive.css?v=2.3.2 HTTP/1.1" 404 342 0.001147 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/admin/css/bootstrap2/admin.css?v=1.1.1 HTTP/1.1" 404 342 0.001148 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2 HTTP/1.1" 404 342 0.001229 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/select2/select2.min.js?v=3.5.2 HTTP/1.1" 404 342 0.001615 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/moment.min.js?v=2.9.0 HTTP/1.1" 404 342 0.005141 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/jquery.min.js?v=2.1.4 HTTP/1.1" 404 342 0.004514 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/jquery.min.js?v=2.1.4 HTTP/1.1" 404 342 0.001098 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2 HTTP/1.1" 404 342 0.001109 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/moment.min.js?v=2.9.0 HTTP/1.1" 404 342 0.001314 ::ffff:127.0.0.1 - - [2017-03-16 12:11:33] "GET /admin/static/vendor/select2/select2.min.js?v=3.5.2 HTTP/1.1" 404 342 0.003048

how to fix it?

  1. find yourPythonPath\lib\site-packages\flask_admin\templates\bootstrap2\admin\static.html
  2. in static.html, modify admin.static to flask-admin.static
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fwiersENO picture fwiersENO  路  4Comments

coreybrett picture coreybrett  路  4Comments

macfire picture macfire  路  6Comments

pmazurek picture pmazurek  路  6Comments

nMustaki picture nMustaki  路  3Comments