π Beanie ODM Support for starlette-admin β Work in Progress #652
Replies: 3 comments 3 replies
-
Hello! π Was working on this a bit for my own project on my fork here. I didn't see the work you did on your branch under "initial commit" until I was pretty deep into my logic π¦ I was able to get the models to show up, sort, and filter as you would expect. Nested pydantic model fields should work using the converter for "BaseModel". Tested the sorting and filtering on string fields for now. Links and list of links are working on my branch as you would expect. Didn't work on BackLinks yet, as this is more complex (no id to reference in the BackLink itself). I build the MongoDB filter queries using the logic from the mongoengine interface, adapted to work with pymongo. I'm sure some complex models will break the logic. To get my fork working with your FastAPI app: Install pip install "git+https://github.com/alexdlukens/starlette-admin.git@beanie"
# or
poetry add "git+https://github.com/alexdlukens/starlette-admin.git@beanie" In your code from starlette_admin.contrib.beanie import Admin, ModelView
admin = Admin()
... call init_beanie() ...
# for each document model you pass to init_beanie
for model in models:
admin.add_view(ModelView(model, name=model.__name__))
admin.mount_to(app) Will try to merge the codebases if I get a chance. Looks like you have more work on the field sorting that I should add to my code. Also haven't added all of the pydantic types one may encounter into the converter, so will fail for some complex models At any rate, hope this helps for your case. Please give it a try and let me know if you have success edit: got some initial tests, copied from mongoengine to work. But having issues getting mypy to pass, because beanie requires Pydantic v2.x. mypy fails when checking on pydantic v1.10.x Best, |
Beta Was this translation helpful? Give feedback.
-
A new commit is now up. It adds the filters option and also allows using the search bar. Next thing I will be working on is OrderBy for the list page. |
Beta Was this translation helpful? Give feedback.
-
@arnabJ, thank you for starting this initiative. I just approved @alexdlukens's pull request #656 to officially support this. You can also take a quick look before it gets merged. |
Beta Was this translation helpful? Give feedback.
-
Hey everyone! π
I'm currently working on a Python package that enables Beanie ODM as a backend for starlette-admin. While starlette-admin already supports several ORMs/ODMs out of the box (like SQLAlchemy, Odmantic, etc.), Beanie isn't officially supported yet.
Following the official guide on creating a custom backend and using Odmanticβs implementation as a reference, I've started building a reusable package that bridges the gap between starlette-admin and Beanie.
π§ Current Status: Work-in-progress
π± Branch: dev
π¬ Feedback/PRs Welcome On: dev-colab
π Repository
π GitHub Repo
π§ͺ Goals
If anyoneβs already attempted this, or has insights, I'd love your feedback! PRs and ideas are welcome on the
dev-colab
branch.Thanks to the maintainers for the extensibility guide β it made this much easier to get started. π
Beta Was this translation helpful? Give feedback.
All reactions