Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
876 views
in Technique[技术] by (71.8m points)

how to get the name instead of reference field in mongoengine and flask -admin

i am trying to assign a specialty for each doctor through admin panel i have created class doctor and it includes a reference field to class medical specialty but when i try to assign specialty to the doctor i get a medical specialty object instead of the name of the specialty

` class Doctor(Document, UserMixin):

name = StringField(required=True)
email = EmailField(required=True) 
password = StringField(required=True)
role = StringField(required=True)
actual_role = StringField(
    choices=['admin', 'doctor', 'patient'], required=True)
confirmed = BooleanField()
specialty = ReferenceField('MedicalSpecialty')`


class MedicalSpecialty(Document):

  specialties = StringField()


class MedicalView(ModelView):
form_columns = ['specialties']



class DoctorView(ModelView):
form_columns = ['name', 'email', 'password',
                'role', 'actual_role', 'confirmed', 'specialty']
column_searchable_list = (
    'name', 'email')


admin.add_view(DoctorView(
Doctor, endpoint='Doctor'))


admin.add_view(MedicalView(MedicalSpecialty, endpoint='MedicalSpecialty'))

[![enter image description here][1]][1]

[![enter image description here][2]][2]

enter image description here

enter image description here

[![enter image description here][5]][5]

[![enter image description here][6]][6]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...