pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.75k stars 1.57k forks source link

Can't configure custom url path for flask admin installation #1837

Open alfredfrancis opened 5 years ago

alfredfrancis commented 5 years ago

Hi, I have flask admin app running under my domain http://10.8.10.22:8080/identity/ which is routed by Traefik. here is my configuration for the app

admin = admin.Admin(app,'Admin',url="/identity/admin")

when i access http://10.8.10.22:8080/identity/admin i get 404. But it's accessible under http://10.8.10.22:8080/identity/identity/admin/ but with broken static file links. I tried different combinations of url and static_url_path , nothing seems to be working properly.

Can you help me resolve this ?

ClintOxx commented 5 years ago

try admin = admin.Admin(app,'Admin',url="/admin")

alfredfrancis commented 5 years ago

@ClintOxx : i did that. now the URL is http://localhost/identity/admin/. All the styles and links are broken. Here is the HTML output. here the links are supposed to be /identity/admin/role/ not /admin/role/


  |  
-- | --
  | <!DOCTYPE html>
  | <html>
  | <head>
  | <title>Home - Admin</title>
  |  
  | <meta charset="UTF-8">
  | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  | <meta name="viewport" content="width=device-width, initial-scale=1.0">
  | <meta name="description" content="">
  | <meta name="author" content="">
  |  
  |  
  | <link href="/admin/static/bootstrap/bootstrap2/swatch/default/bootstrap.min.css?v=2.3.2" rel="stylesheet">
  | <link href="/admin/static/bootstrap/bootstrap2/css/bootstrap-responsive.css?v=2.3.2" rel="stylesheet">
  | <link href="/admin/static/admin/css/bootstrap2/admin.css?v=1.1.1" rel="stylesheet">
  |  
  | <style>
  | body {
  | padding-top: 4px;
  | }
  | </style>
  | </head>
  | <body>
  |  
  | <div class="container">
  | <div class="navbar">
  | <div class="navbar-inner">
  |  
  | <a class="brand" href="/admin">Admin</a>
  |  
  |  
  | <ul class="nav">
  |  
  |  
  | <li class="active">
  | <a href="/admin/">Home</a>
  | </li>
  | <li>
  | <a href="/admin/user/">User</a>
  | </li>
  | <li>
  | <a href="/admin/role/">Role</a>
  | </li>
  | <li>
  | <a href="/admin/status/">Status</a>
  | </li>
  | <li>
  | <a href="/admin/subscription/">Subscription</a>
  | </li>
  |  
  | </ul>
  | <ul class="nav pull-right">
  | </ul>
  |
  | </div>
  | </div>

  | </div>

  | <script src="/admin/static/vendor/jquery.min.js?v=2.1.4" type="text/javascript"></script>
  | <script src="/admin/static/bootstrap/bootstrap2/js/bootstrap.min.js?v=2.3.2" type="text/javascript"></script>
  | <script src="/admin/static/vendor/moment.min.js?v=2.9.0" type="text/javascript"></script>
  | <script src="/admin/static/vendor/select2/select2.min.js?v=3.5.2" type="text/javascript"></script>

  | </body>
  | </html>
ClintOxx commented 5 years ago

Do you have like a folder tree or something to i can see where these files lay in relation to this html template?

usually if im using the jinga templates i use {{ url_for('apis.upvote_key') }}

and in the upvote_key route i would return render_template('upvote.html') which points at the location of the template.

its been awhile since ilook into how flask-admin handles links to templates but it should be the same