Implementation multiple admin panels#1027
Conversation
|
@MaximDementyev right now, im reviewing smaller PRs, I need enough time for focus to review this, so it can take time. I have not forgotten about this one) |
|
The FastApi 0.137.0 update has broken the routers.routers traversal logic. If implementing any url search logic seems complicated, you can consider creating a function like this: This will allow you to collect all the URL search logic in one place, giving users the ability to override this function. |
|
This is incomplete. I am putting this to draft for now. Here are things that should be considered/fixed
So if two admin have different ajax_lookup_urls, it will be messed up
OR: Inside an admin request, |
Problem
It is not possible to add multiple administration panels within the same application
fix Multiple Admin Panels for the same fastapi App #919
Solution
local_url_for - Generate a URL for the specified route, taking router hierarchy into account.
get_current_router_name - Find the router name in the hierarchy that corresponds to the target router. Traverses the routes of the start router and its nested applications (of type
Mount) to find a match with the target router.The entire project has updated the use of request.url_for to local_url_for.
This made it possible to run multiple sqladmins within the same application, and also remove the restriction that SqlAdmin can only be connected to the FastApi root application.
In the example, three administration panels are connected that are connected to different databases
admin1 is accessible via the path /admin/base1
admin2 is accessible via the path /admin/base2
admin3 is accessible via the path /api/admin/base3
If this solution is suitable, I will update the documentation and add tests for new functions.