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.8k stars 1.58k forks source link

Mongoengine Support in Version 2 #2541

Open Bastian-Kuhn opened 1 month ago

Bastian-Kuhn commented 1 month ago

Hello team,

First of, thank you very much for flask-admin. As already mentioned, in this ticket, my tool heavily depends on mongoengine.

After some first proof of concepts, I found that migration to pymongo would be a huge step backwards. It's for my program, which basically consists of DB Models like a rewrite with fewer features and comfort after. (Example Filters also missing)

As a replacement for flask-mongoengine I found flask-mongoeine-3 which works well, and can replace the old one without any changes of code.

for flask-admin I was able with just some lines of code to make the contrib/mongoengine work again. And my Plan B would to just ship that part with my Project. But since I'm sure others could use it too, I want to ask why It can't stay as part of the flask-admin? I need to fix it anyway for me to keep it working, so I could also help with Pull Requests. I just would need to change everything in order that the tests work again. But the function is already there by changing two imports.

Best Bastian

samuelhwilliams commented 4 weeks ago

Thanks for the update. Disappointing to hear that pymongo doesn't look like a feasible replacement.

flask-mongoengine-3 is broadly an option. My initial concern is that it appears to quite inactive as far as maintenance goes, and doesn't seem to have a broad base of support (in terms of maintainers).

I'm not really against it per se, but bear in mind I have no personal motivation either as I don't use mongo in my day-to-day so it's not work I'd be heavily invested in.

Flask-Admin is a community maintained project so I think it would be very possible for you to look at adding support for flask-mongoengine-3 back (which hopefully may not be much harder than reverting the PR which took it away and making whatever tweaks/changes are needed for -3 support).

Maybe join the Pallets discord and check out the #pallets-eco channel? I'm happy to look at PRs you put up adding support (back) for it, as and when I can

karpitsky commented 3 weeks ago

Hello,

My Flask app uses pure MongoEngine and Flask-Admin, and it works perfectly, thanks! Maybe there's an option to remove the Flask-MongoEngine dependency but keep MongoEngine.

As far as I can see, the current version of Flask-Admin uses only the orm and fields functionality from Flask-MongoEngine in the form.py file, but everything else is from MongoEngine.

Additionally, the orm module is deprecated in Flask-MongoEngine.

Bastian-Kuhn commented 3 weeks ago

As far as I can see, the current version of Flask-Admin uses only the orm and fields functionality from Flask-MongoEngine in the form.py file, but everything else is from MongoEngine.

But isn’t that a crucial part of the code, given its responsibility for the WTF Forms? Otherwise, I could start exploring alternatives, possibly by shifting the related logic from flask_mongoengine into the flask_admin module.

karpitsky commented 3 weeks ago

I've just tried to replace Flask-MongoEngine imports with MongoEngine and WTForms and it's working fine for me.

Here's the diff.

To be honest, I haven't tested all the field types yet.

Bastian-Kuhn commented 2 weeks ago

Good idea to remove the requirement completely, will test that. It just will take me some days to start, much to do currently. Thank you very much already.

samuelhwilliams commented 1 day ago

I've just tried to replace Flask-MongoEngine imports with MongoEngine and WTForms and it's working fine for me.

If this is workable, it sounds like a very positive idea and alleviates concerns around maintenance issues with flask-mongoengine and its forks 👍

Bastian-Kuhn commented 1 day ago

@karpitsky I just tested your fixed version of forms.py and It works fine. Perfect