Skip to content

Conversation

Bastian-Kuhn
Copy link
Contributor

Thanks to @karpitsky this brings back the support for Mongoengine, but without the dependency of flask-mongoengine.

Reference: #2541

@Bastian-Kuhn
Copy link
Contributor Author

Only known Problem yet is with the Widgets, but that could be related to an outdated wtforms version.

Also waiting for the tests.

@LeXofLeviafan
Copy link
Contributor

Note: you may want to run the style tests before making the commit (they auto-fix the code style).

I believe it can be done via tox (i.e. tox -e style).

@ElLorans
Copy link
Contributor

Note: you may want to run the style tests before making the commit (they auto-fix the code style).

I believe it can be done via tox (i.e. tox -e style).

pip install pre-commit should be enough to do it automatically when committing. Running pre-commit run --all-files allows to do it before committing as well.

@Bastian-Kuhn
Copy link
Contributor Author

Note: you may want to run the style tests before making the commit (they auto-fix the code style).

I believe it can be done via tox (i.e. tox -e style).

Oh thanks, this command changed a lot :)

@Bastian-Kuhn
Copy link
Contributor Author

About the last Tests, Typing, my guess would be to change the requirements/typing.in to add mongoengine?
But what is the proper way for that?

@LeXofLeviafan
Copy link
Contributor

I imagine you need to add mongoengine to the list of packages within that file, then rerun the command written in the .txt file 🙃

(Or possibly mongo-types is what should be added… it could be outdated tho 🤔)

@samuelhwilliams
Copy link
Contributor

samuelhwilliams commented Apr 24, 2025

Yep @LeXofLeviafan is right - if we're adding mongoengine back, we need to add it to our dependency files. This can be a bit of a pain because of how we/pip manages them across multiple files (and probably a good incentive to switch to something more like uv soon...)

Let me know if you need a hand and I can try to help (/work out exactly what to do).

@LeXofLeviafan
Copy link
Contributor

So… any news on this yet?

@Bastian-Kuhn
Copy link
Contributor Author

So… any news on this yet?

If someone could help me with the final check would be nice. Don't want to break something.
And then, that's on me, I need to fix the Bug with the Widgets.

Then everything would be done :)

@ElLorans
Copy link
Contributor

Yep @LeXofLeviafan is right - if we're adding mongoengine back, we need to add it to our dependency files. This can be a bit of a pain because of how we/pip manages them across multiple files (and probably a good incentive to switch to something more like uv soon...)

Let me know if you need a hand and I can try to help (/work out exactly what to do).

Samuel, can you update or tell us how to update the dependencies for type checking? or can I just try to add mongoengine to requirements/typing.txt and run checks locally?

@LeXofLeviafan
Copy link
Contributor

Samuel, can you update or tell us how to update the dependencies for type checking? or can I just try to add mongoengine to requirements/typing.txt and run checks locally?

@samuelhwilliams I believe this was a question for you 😅

@ElLorans based on the comment within that file, the correct answer appears to be "place mongoengine (or mongo-types?) within typing.in then run pip-compile typing.in to update typing.txt"

@samuelhwilliams
Copy link
Contributor

Argh very sorry - thank you for the nudge. Let me give it a go now - it's quite awkward at the moment to get all of the versions of things in different files compatible.

More justification for us/me to switch us over to uv ASAP, probably.

@samuelhwilliams
Copy link
Contributor

samuelhwilliams commented Jun 1, 2025

re: type hints, this issue on mongoengine suggests that the package doesn't really have type hinting support. It mentions an alternative, mongo-types, that also seems outdated and incomplete.

We might want to just disable type hinting on the mongoengine (for now / forever) package by adding it to the ignore_missing_imports block of mypy overrides in pyproject.toml.

In this case no updates will be needed to the requirements files so avoids that sometimes-painful step. But for future reference the principle is vaguely:

  • set up a virtualenv with the correct python version (Based on the header in the *.txt requirements files.
  • Activate the venv and install pip-tools.
  • Run pip-compile on each of the affected requirements files in this order:
    • build.in (only if build.in changed)
    • tests.in (only if tests.in changed)
    • docs.in (if tests.txt or docs.in changed)
    • typing.in (if tests.txt or typing.in changed)
    • dev.in (if docs.txt, tests.in, typing.txt or dev.in changed)

Copy link
Contributor

@samuelhwilliams samuelhwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also need some amount of test coverage when you get happy with the functionality :)

@LeXofLeviafan
Copy link
Contributor

@Bastian-Kuhn …Any news on this? 😅

@Bastian-Kuhn
Copy link
Contributor Author

Hello @LeXofLeviafan

Yes, currently just the Exception from here left: #2541 which I was hoping for help but of course will try to debug it again. And then about testing where someone needs to decide how to go on, to either ignore the typing hints or that I should update the requirements file like described.

Copy link
Contributor

@LeXofLeviafan LeXofLeviafan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the testing typehints: if I got what @samuelhwilliams said right, you could try mongo-types but if that doesn't work out the only other option would be to turn them off for mongo.

@ElLorans
Copy link
Contributor

Is there any to-do left on my site? Or any other help needed?

I resolved all open conversations, so if the other contributors approve the new edits and have nothing else to add, no.

@LeXofLeviafan
Copy link
Contributor

if the other contributors approve the new edits

Approving would be tricky for me… since I don't have access to do so 🙃

That being said, I don't have any new comments regarding the code; so I guess what's left is to get approval from @samuelhwilliams

…Is this the last item to tackle before (finally!) completing the 2.0 release? Or will someone pick up the DeprecationWarnings thing? 🤔

@samuelhwilliams
Copy link
Contributor

Thanks for the nudge. I've been following this loosely but if we think it's ready to go now, I'll have a last look and play and see if I can find any outstanding blockers. If not then let's get it merged and hopefully get 2.0 over the line 🤞

@samuelhwilliams
Copy link
Contributor

Using the mongoengine example and trying to apply a filter throws this error - anyone able to investigate (and validate other common flask-admin usecases)

2025-10-04 14 33 52

@LeXofLeviafan
Copy link
Contributor

LeXofLeviafan commented Oct 4, 2025

@samuelhwilliams I believe including a static screenshot would be a big help when trying to investigate 😅
traceback
…Though I'm not sure if it includes actual location of the error 🤔

@samuelhwilliams
Copy link
Contributor

Fair points, sorry - but hopefully the instructions on how to reproduce are quite straight-forward :)

@ElLorans
Copy link
Contributor

ElLorans commented Oct 4, 2025

TBH, I liked the GIF. I implemented a bugfix, but I think we need a unit test for this. @Bastian-Kuhn, I removed .name from the filters. do you remember why it was there? Maybe I am missing something.

@samuelhwilliams
Copy link
Contributor

Nice, have checked out and agree that seems to have fixed it @ElLorans 👍

A test would be nice, agreed.

@ElLorans
Copy link
Contributor

ElLorans commented Oct 5, 2025

Nice, have checked out and agree that seems to have fixed it @ElLorans 👍

A test would be nice, agreed.

I added a simple one:

    # Filter: test1 equals "test1large"
    rv = client.get("/admin/testview/?flt1_0=test1large")
    assert rv.status_code == 200
    data = rv.data.decode("utf-8")
    assert "test1large" in data
    assert "test1small" not in data

    # Filter: test2 equals "test2"
    rv = client.get("/admin/testview/?flt2_0=test2")
    assert rv.status_code == 200
    data = rv.data.decode("utf-8")
    assert "test2large" not in data
    assert "test2" in data

@samuelhwilliams
Copy link
Contributor

samuelhwilliams commented Oct 6, 2025

I think I'm happy enough at this point. Can I get a few other reviews as well please? :) Let's plan to merge this by the end of the week and then we should be in a place to do a v2.0.0 rc release - if not the full thing. 👍 🙇

Note that, for better or worse, I have mainly focused on a usability review rather than a line-by-line code review.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for MongoEngine in Flask-Admin v2.0 by removing the dependency on flask-mongoengine while maintaining full functionality for MongoDB document management.

  • Adds mongoengine optional dependency configuration
  • Updates translation files with new MongoEngine-specific strings
  • Restores MongoEngine support without flask-mongoengine dependency

Reviewed Changes

Copilot reviewed 58 out of 96 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Adds mongoengine optional dependency and build configuration
flask_admin/translations/**/admin.po Updates translation files with MongoEngine filter and view messages

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ElLorans ElLorans self-requested a review October 8, 2025 13:51
Copy link
Member

@hasansezertasan hasansezertasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @Bastian-Kuhn, thank you for contributing 🙏.

Note that, for better or worse, I have mainly focused on a usability review rather than a line-by-line code review.

I did the same, the example looks great 🤓.

@samuelhwilliams
Copy link
Contributor

Thanks everyone (@Bastian-Kuhn @LeXofLeviafan @ElLorans @hasansezertasan) for the huge effort involved in getting this support back in 🙇 Feels really good to be able to keep this.

@samuelhwilliams samuelhwilliams merged commit 759d4da into pallets-eco:master Oct 9, 2025
12 checks passed
@Bastian-Kuhn Bastian-Kuhn deleted the mongoengine branch October 9, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants