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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:22:26+00:00 2026-06-16T07:22:26+00:00

The Django admin docs says that it is possible to specify a callable as

  • 0

The Django admin docs says that it is possible to specify a callable as a value that can be used in list_display. If I need to pass some extra context to the function via function arguments, what’s the best way to accomplish that?

In pseudo code, what I’d like to do is something like:

App realestate:

models.py:

class A(models.Model):
    raw = models.TextField()

admin.py:

from utils import processing

list_display = [processing('realestate app result', True)]

App party:

models.py:

class Person(models.Model):
    raw = models.TextField()

admin.py:

from utils import processing

list_display = [processing('party app result', False)]

utils.py:

def processing(obj, short_description, allow_tags=False):
    def process(obj):
        # do something
        pass
    process.short_description = short_description
    process.allow_tags = allow_tags

    return process(obj)
  • 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-16T07:22:27+00:00Added an answer on June 16, 2026 at 7:22 am

    You should not specify the short_description and allow_tags inside the function itself.

    define processing like this:

    utils.py:

    def processing(obj):
          #do something
          pass
    

    on each ModelAdmin class, do:

    class RealestateAdmin(...):
       list_display = [processing,]
    
       def processing(obj):
           return utils.processing(obj)
       processing.short_description = 'realestate app result'
       processing.allow_tags = True
    
    
    class PartyAdmin(...):
       list_display = [processing,]
    
       def processing(obj):
           return utils.processing(obj)
       processing.short_description = 'party app result'
       processing.allow_tags = False
    

    So you have one place (utils.py) which contains the logic.
    And every class defines the properties to display in the table.

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

Sidebar

Related Questions

I'm using django-admin-tools 0.4. Following the docs here so that I can get a
Reading about Django, I saw this: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin - the fancy simple to use admin
The Django admin site makes use of a really cool widget: How can I
Can Django admin site select entries by a custom date range, i.e. using two
The django admin allows you to specify fieldsets . You properly structure a tuple
Is it possible to implement column level permissions per user in the Django admin
This is my urlconf( taken from the Django docs) urlpatterns = patterns('', url(r'^admin/password_reset/$', 'django.contrib.auth.views.password_reset',
Using Django 1.1: The Django admin docs describe using arbitrary methods or attributes on
I want to create a Django Admin Action that allows me to create a
By default, I can see Delete the selected user action from django user admin

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.