Comments (2)
So I finally got it to work, but its ugly. I had to use the User SQLAlchemy instance and override its eq to check if the id fields were equal. The part where it checks if something should be selected does == between the user object populating the form and the one stored in form.select_field.data. That fails because they are different instances. However changing the comparison operator fixes the problem in this case.
class ApplicationModelView(ModelView):
def create_form(self, obj=None)
form = super().create_form(obj=obj)
form.select_field.data = user_obj
return form
class User(Base):
def __eq__(self, other):
return isinstance(other, type(self)) and self.id == other.id
Use this at your own risk, I have no idea if there are unintended consequences.
from flask-admin.
Are you able to provide a minimal reproduction code snippet for the problem you've flagged in the first post? Would be happy to investigate if this is still an issue; it feels like you shouldn't need to resort to JS or overriding __eq__
.
from flask-admin.
Related Issues (20)
- Add Pallets-eco notice
- Mirror Pallets-eco setup for projects HOT 4
- Comparasing between objects causes crash if _eq_ of db model class is "occupied" HOT 24
- Disable typing in tests
- Add typing support to project HOT 1
- Deprecate flask-babelex; use flask-babel again
- Template Mode w/ Tabler
- Remove Flask-BabelEx support? HOT 2
- Update Python compatibility
- Plan for next release - v2.0 HOT 21
- Use `extras` to define packaging options and their dependencies
- Remove (flask-)mongoengine support? HOT 2
- Add some tests for JS components HOT 4
- Add a test that runs all of the examples
- Fix width (and check functionality) of mapbox search text input
- flask-admin nested-admin
- Inconsistent headers in modals
- Filter 'Apply' Button Visibility Issue Introduced in PR #2501 HOT 2
- Multiple issues when using `StrictUndefined` in app.jinja_env.undefined HOT 1
- Compatibility with flask async routes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-admin.