2014-12-03 76 views
0

我有以下型號:我可以在manyToMany自動生成的模型中指定詳細名稱嗎?

class Doctor(models.Model): 

    #some attributes... 

    class Meta: 
     verbose_name = _(u'doctor') 
     verbose_name_plural = _(u'doctors') 


class Patient(models.Model): 

    #some attributes... 
    medical_consult = models.ManyToManyField(Doctor) 

    class Meta: 
     verbose_name = _('patient') 
     verbose_name_plural = _('patients') 

有什麼辦法來設置verbose_name當我使用ManyToManyField自動創建模型Patient_doctor

回答

0
medical_consult = models.ManyToManyField(Doctor, through='PatientDoctor') 

# ... 

class PatientDoctor(models.Model): 
    patient = models.ForeignKey(Patient) 
    doctor = models.ForeignKey(Doctor) 
    # ... 

    class Meta: 
     verbose_name = _('patient_doctor') 
     # ... 
相關問題