Comments (8)
Blueprint name collision happens because you need unique endpoint
names for each view. If endpoint
is not explicitly passed to the constructor, it will be automatically generated and might collide with other views.
I modified multi.py
example to illustrate how to avoid name collisions: https://gist.github.com/mrjoes/b42defe0f420097f40c7
from flask-admin.
The issue is if you don't set an index_view when creating the Admin instance (ex. admin = Admin(index_view=SomeView)
), the extension will create an instance of AdminIndexView, which creates a blueprint at the same endpoint ('admin'). I tried to get around this myself by setting an index_view for my second instance of Admin, but there is a hard check to make sure only 1 instance of the extension exists for the app (see: https://github.com/mrjoes/flask-admin/blob/master/flask_admin/base.py#L442).
I was looking to create multiple Admin instances for different levels (Global admin, Organization admin, etc). I think part of the issue with having more than 1 instance will be how the templates can generate the UI with more than 1. I was a bit surprised that each View within the extension is a blueprint, and not just 1 blueprint for the extension (maybe I'm not understanding the code flow).
@mrjoes your thoughts on supporting multiple instances?
from flask-admin.
It is not a problem to support multiple Admin
instances per one Flask application. Will require some changes in localization support, but it should not be a big deal.
There are few reasons why each view is encapsulated into separate blueprints: views are independent of each other, it is possible to use Flask built-in blueprint helpers (like url_for('.view')
to get "local" URLs) and so on.
As for the administrative interface structure: I'd go with permission based approach. If is_accessible()
returns False for the view, it won't be displayed in menu either. So, you can create few base classes (or mixins) one for each administrative "level". Then, compose your admininstrative interface using these pieces.
I guess having separate administrative interfaces might also work as well, but each "level" will be its own UI.
from flask-admin.
@mrjoes Exactly, I've made a work around by creating multiple views with different implementations of is_accessible().
I guess the different UIs might be something to consider. For instance:
/app/admin - contains user data/global objects
/app/sub-app/admin - contains app specific stuff but uses user/global objects
Could have a need for separate UI views.
from flask-admin.
That was fast, thanks. I'll be trying this out in the next few days and will report any issues.
from flask-admin.
I set this up without any issue. Thanks again.
from flask-admin.
This doesn't work for me (1.0.5). I have one instance configured in file1 and another in file2 with a similar set of models configured but with different configurations (column_list etc). I have passed a different url and endpoint to each Admin instance, but when i import and init_app these i get a blueprint name collision.
from flask-admin.
Awsome thanks, i new i was missing something obvious
from flask-admin.
Related Issues (20)
- Bootstrap4: Duplicate requests when opening modal windows
- Intercepting and executing custom code on object creation/update in flask-admin HOT 2
- How to use form_overrides on ListField(StringField)?
- `rediscli` command names should be treated case-insensitively
- Enhancement: Allow page_size_options = [15,30,60] to override 20,50,100 hard coded into page_size_form layout HOT 1
- Error launching the examples using Python 3.12 HOT 1
- QueryAjaxModelLoader and additional filters
- Please update the requirements.txt in examples/sqla/ HOT 1
- Can't use column_filters with peewee ForeignKeyField
- aioflask with Flask>=3.0
- Form column is not being displayed if it starts with underscore "_" HOT 7
- Unable to Render Flask-Admin Edit Form Fields for Variables Stored as JSON HOT 1
- Seeking help from additional volunteers? HOT 7
- Creating custom views for BaseView grouped in a category and passing an id HOT 1
- Can't use multiple `Admin` instances with different Bootstrap themes (`FLASK_ADMIN_SWATCH`) HOT 14
- Flask Admin Reboot: A community version to submit changes HOT 6
- [not issue] Implement flask-admin in Go HOT 2
- QuerySelectField ignores changes to data / default in ModelView.create_form HOT 2
- `can_set_page_size` does not prevent custom page sizes
- Multiple requests caused by 'create_modal' HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-admin.