How could I put the admin code in a custom Python file named admin.py instead of the file where the FastAPI instance is located? #749
Answered
by
im-redactd
ChengChe106
asked this question in
Q&A
-
I put the admin code in a custom Python file named admin.py, but when I try to access http://127.0.0.1:8080/admin/, it shows "Not Found". This is my code. from sqladmin import Admin, ModelView from src import app admin = Admin(app, engine) class UserAdmin(ModelView, model=User): admin.add_view(UserAdmin) |
Beta Was this translation helpful? Give feedback.
Answered by
im-redactd
Apr 23, 2024
Replies: 1 comment 5 replies
-
I think the solution for this could be a more like a Flask Admin approach, meaning: ...
admin = Admin()
app =...
admin.init_app(app)
... |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do this now and it's fairly easy.
folder structure for my example is
In your main.py
your app/admin/setup.py would look like this
your app/admin/views/user_admin.py - you may not need to go to this level of organization if you don't have a lot of views and you coul…