# Display verbose name on profile page Django DetailView (specific model instance)

**URL:** <https://forum.djangoproject.com/t/display-verbose-name-on-profile-page-django-detailview-specific-model-instance/16981>\
**Category:** Templates & Frontend\
**Created:** [November 12, 2022, 1:23pm UTC](https://forum.djangoproject.com/t/display-verbose-name-on-profile-page-django-detailview-specific-model-instance/16981 "2022-11-12T13:23:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathanlewis99](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nathanlewis99/32/10825_2.png) [@Nathanlewis99](https://forum.djangoproject.com/u/Nathanlewis99)\
**Post date:** [November 12, 2022, 1:23pm UTC](https://forum.djangoproject.com/t/display-verbose-name-on-profile-page-django-detailview-specific-model-instance/16981/1 "2022-11-12T13:23:41Z")

</div>

I am working on a page to display a users profile. I have successfully rendered an instance of the users profile, which looks as shown in the screenshot below. The thing I want to change, is to display the verbose name of the field names, rather than the actual field name. I have done some research but am not sure how to implement this with my current set up.

My models.py:

```auto
class Profile(models.Model): 
    MALE = 'M'
    FEMALE = 'F'
    OTHER = 'O'
    UNSPECIFIED = "U"
    GENDER_CHOICES = [
        (MALE, 'Male'),
        (FEMALE, 'Female'), 
        (OTHER, 'Other'),
        (UNSPECIFIED, 'Prefer not to say'),
    ]

    user = models.OneToOneField(User, on_delete=models.CASCADE)
    phone_number = models.CharField(verbose_name='Mobile Phone Number', max_length=20)
    bio = models.TextField(verbose_name='Bio', max_length=500, blank=True, null=True)
    date_of_birth = models.DateField(verbose_name='Date of Birth', blank=True, null=True)
    first_name = models.CharField(verbose_name='First Name', max_length=255, blank=True, null=True)
    surname = models.CharField(verbose_name='Surname', max_length=255, blank=True, null=True)
    gender = models.CharField(verbose_name='Gender', max_length=255, choices=GENDER_CHOICES, blank=True, null=True)
    emergency_contact_name = models.CharField(verbose_name='Emergency Contact Name', max_length=255, blank=True, null=True)
    emergency_contact_number = models.CharField(verbose_name='Emergency Contact Number', max_length=20, blank=True, null=True)
    business = models.ForeignKey(BusinessProfile, null=True, blank=True, on_delete=models.SET_NULL)
    creation_date = models.DateTimeField(auto_now_add=True)

    def __str__ (self):
        return str(self.user)

```

Views.py:

```auto
class ShowProfileView(DetailView):
    model = Profile
    template_name = 'profiles/user_profile.html'

    def get_context_data(self, *args, **kwargs):
        context = super(ShowProfileView, self).get_context_data(*args, **kwargs) # super gives access to parent class methods
        user_profile = get_object_or_404(Profile, id=self.kwargs['pk']) # 'id' is representative of the <int:pk> tag in the url. This means could change 'pk' to be 'id' in both view and url files, and it would still work. So within the url 'pk' is the dictionary key,
        # and the actual value which is passed into the url (that you see in the search bar) is the dictionary value. 
        context["user_profile"] = user_profile
        return context

    def get_object(self, *args, **kwargs):
        obj = Profile.objects.filter(id=self.kwargs['pk']).values('first_name', 'surname', 'date_of_birth', 'phone_number', 'bio', 'date_of_birth', 'gender', 'emergency_contact_name', 'emergency_contact_number') # list of dictionaries
        object = obj[0]
        return object

```

user\_profile.html:

```auto
    {% extends "base.html" %}

    {% block content %}

        <h1>Profile</h1>
        <br/><br/>
        {% csrf_token %}
        <ul>
        {% for k, v in object.items %}
        <p>{{ k }}: {{ v }}
        {% endfor %}
        </ul>
        <a href='{% url "profiles:edit_profile" pk=user.profile.id %}'>Edit Profile</a>

    {% endblock %}  

```

And a screenshot of how this looks: [![enter image description here](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/e/e0eff5bc35f7d06d436a67146de74efc816fb29c.png)](https://i.stack.imgur.com/atPuC.png)

Any help much appreciated! Thanks.

---

<div class="post-metadata">

**Author:** ![biscotty666](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/biscotty666/32/10522_2.png) [@biscotty666](https://forum.djangoproject.com/u/biscotty666)\
**Post date:** [November 12, 2022, 3:06pm UTC](https://forum.djangoproject.com/t/display-verbose-name-on-profile-page-django-detailview-specific-model-instance/16981/2 "2022-11-12T15:06:05Z")

</div>

I believe that you could create a ModelForm and pass that instead of your object. That would allow you to assign labels to each field with something like labels = {‘field’:‘displayName’}.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 12, 2022, 3:41pm UTC](https://forum.djangoproject.com/t/display-verbose-name-on-profile-page-django-detailview-specific-model-instance/16981/3 "2022-11-12T15:41:04Z")

</div>

See the discussion at [How to display verbose\_name in HTML template](https://forum.djangoproject.com/t/how-to-display-verbose-name-in-html-template/11738)
