Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:06:47+00:00 2026-06-09T20:06:47+00:00

I would like to display the model’s username in Django Admin interface but not

  • 0

I would like to display the model’s username in Django Admin interface but not very sure how to do it..

The models.py:

    class Adult(models.Model):    
        user = models.OneToOneField(User)
        fullname = models.CharField(max_length=100,
                                    blank=True)
        def __unicode__(self):
            return self.user.username

Admin.py:

    class AdultAdmin(admin.ModelAdmin):
        list_display = ('??', 'Student_Name',)
        search_fields = ['??',]

    admin.site.register(Adult, AdultAdmin)

What should go inside the ?? above ? I would like to display the unicode or the self.user.username? How do i do it? Need some guidance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:06:49+00:00Added an answer on June 9, 2026 at 8:06 pm

    From the list_display documentation there are four things you can add there:

    1. A field
    2. Some method (a callable) that accepts one variable that is the instance for which the row is being displayed.
    3. A string that is the name of a method or attribute defined in the model class.
    4. A string that is the name of a method that is defined in ModelAdmin.

    For your case we need #3 for list_display.

    For search_fields its easier as you can use follow notation (__) to do lookups.

    In the end we come up with this:

    class AdultAdmin(admin.ModelAdmin):
        list_display = ('__unicode__', 'Student_Name',)
        search_fields = ['user__username']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to display the function name in search fields in Django Admin
I have DirectX .x files and I would like to display the model in
In Delphi 7, I have a model dialog and i would like to display
I would like to display other we pages in my mobile webapp, but some
I would like to display a 3D model in a WPF application (the model
I'm trying to model a simple ledger in Django and would like to clear
Am looping through a set of records and would like to display the model's
I would like to display the details of the first model in Backbone by
I would like to display some content located in my models in some of
I would like to achieve the following: On homepage load, display modal box Within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.