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 8385671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:43:56+00:00 2026-06-09T17:43:56+00:00

I would like to display the function name in search fields in Django Admin

  • 0

I would like to display the function name in search fields in Django Admin interface but when i do it

The models.py:

class Adult(models.Model):    
    user = models.OneToOneField(User)
    firstname = models.CharField(max_length=100,
                                blank=True)
    lastname = models.CharField(max_length=100,
                                blank=True)
    def __unicode__(self):
        return self.user.username
    def Parent_Name(self):
      try:
        return '%s %s' % (adult.firstname,adult.lastname)
      except Exception:
        return ''
    getParentName.shot_description = 'adult'

Admin.py:

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

admin.site.register(Adult, AdultAdmin)

Error:
Cannot resolve keyword ‘Parent_Name’ into field.

What should be the correct way of writing this so that the function name can be used for search_fields?

  • 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-09T17:43:57+00:00Added an answer on June 9, 2026 at 5:43 pm

    The search_fields should be:

    … set to a list of field names that will be searched whenever somebody submits a search query in that text box.

    You can’t specify your own search function, as it only accepts a list of strings indicating the fields you want to search (unlike the list_display option that you have mentioned which does accept functions – allowing you to programmatically return the value of the list item).

    You can see the appropriate code that deals with search_fields here (and it’s limitations) on github. The best you can do is follow relationships.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to debug a function. I would like to display warnings when
I would like to display the first and last name of the authenticated user.
I would like to display other we pages in my mobile webapp, but some
I would like to display area tag name after a person clicks on it.
I would like to display a * in my prompt if the name of
I have managed to display data in one column table, but would like to
This code displays times zones vertically. I would like to display them horizontally but
I would like to display the image of two real valued analytic functions f,g
I would like to display a gallery of photos and how many times each
I would like to display a loading bar before the entire page is loaded.

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.