I have this model:
class WeaponClass(models.Model):
"""Table with all possible weapon classes."""
label = models.CharField(max_length=32)
acronym = models.CharField(max_length=8)
class Meta:
ordering = ['id']
verbose_name_plural = 'weapon classes'
def __str__(self):
return f"{self.label}, {self.acronym}"
with this serializer:
class WeaponClassSerializer(serializers.HyperlinkedModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name="weapon_classes-detail")
class Meta:
model = WeaponClass
fields = ['url', 'label', 'acronym']
Now, I have player, that has weapon class:
class PlayerSerializer(serializers.HyperlinkedModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name="players-detail")
user = UserSerializer()
weapon_class = WeaponClassSerializer()
class Meta:
model = Player
fields = ['url', 'user', 'weapon_class']
When I display player, everything is working perfectly how I want it, except for one thing. When I view browsable API from django rest framework, Weapon Class name in HTML form is outputting <BoundField value=Medium Bruiser errors=None>. It should output 'Weapon Class', just like the part with 'User'. When I open Weapon Class, title on that page is normal, it says 'Weapon Class Instance', same as 'Player Instance' in pictures below. Its not affecting anything, but I'm really wondering why is it doing this:

I circled the problem.