1

In my django-admin it is displaying the foreign-key id value instead of the name value of the foreign key. How can I display the actual name value. I tried the str method for my foreignkey model, but doesn't change anything.enter image description here

class DemoPractice(models.Model):
    def __str__(self):
        return u'%s' % (self.PracticeName)
    Group = models.ForeignKey('DemoGroup', on_delete=models.CASCADE)
    PracticeName = models.CharField(max_length=255, null=True, blank=True)
    Primary = models.BooleanField(null=False, blank=False, default=True)
    ServiceAddressLine1 = models.CharField(max_length=255, help_text='New York', null=True, blank=True)
    ServiceAddressLine2 = models.CharField(max_length=255, help_text='New York', null=True, blank=True)
    ServiceAddressCity = models.CharField(max_length=255, help_text='New York', null=True, blank=True)
    ServiceAddressState = models.CharField(max_length=255, help_text='New York', null=True, blank=True)
    ServiceAddressZip = models.CharField(max_length=255, help_text='New York', null=True, blank=True)
    ServiceAddressCounty = models.CharField(max_length=255, help_text='10007', null=True, blank=True)
    OfficePhone = PhoneField(blank=True, help_text='1234567890 - 10 digits')
    OfficeFax = PhoneField(blank=True, help_text='1234567890 - 10 digits')
    OfficeEmail = PhoneField(blank=True, help_text='1234567890 - 10 digits')
vee
  • 680
  • 1
  • 10
  • 27

1 Answers1

0

the issue is you need to remove all other special formatting fields (e.g. filter_horizontal) and use raw_id_field only.

vee
  • 680
  • 1
  • 10
  • 27