You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using mongoengine and I have some issues when using Flask Admin.
If I have a Embedded document or ReferenceObject, the admin just shows EMail object or User object or <class_name> object in general. Seems as though these are just being converted to strings - which is not a very correct way to do this.
When I try to create a model which has a Reference field, I get a drop down with every element as User Object - which is very confusing as I have no idea what their id is !
For displaying I suggest you use links with the Object id or something.
The text was updated successfully, but these errors were encountered:
You have to overload a method __str__ (for Python 3) or __unicode__ (for Python 2):
# for python3
class Email (db.Document):
value = db.StringField()
def __str__(self):
return self.value
class User (db.Document):
name = db.StringField()
email = db.ReferenceField(Email)
def __str__(self):
return 'My name is %s and email is %s' % (self.name, self.email.value)
I'm using mongoengine and I have some issues when using Flask Admin.
If I have a Embedded document or ReferenceObject, the admin just shows
EMail object
orUser object
or<class_name> object
in general. Seems as though these are just being converted to strings - which is not a very correct way to do this.When I try to create a model which has a Reference field, I get a drop down with every element as
User Object
- which is very confusing as I have no idea what their id is !For displaying I suggest you use links with the Object id or something.
The text was updated successfully, but these errors were encountered: