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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:30:57+00:00 2026-05-26T16:30:57+00:00

In the Django admin index page, the app and its models will normally be

  • 0

In the Django admin index page, the app and its models will normally be listed. How can the model objects also be listed in this index page? Instead of displaying just the app, I want to also display its model objects. How should it be customized?

enter image description here

  • 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-05-26T16:30:58+00:00Added an answer on May 26, 2026 at 4:30 pm

    I wanted the same functionality for my site and added it by doing slight modifications to the core django system.

    Step 1:
    First we need a way to indicate which models should have their properties listed. Add the following code to the models for which you want the instances listed (in models.py):

    class Meta:
        list_instances = True
    

    Step 2:
    We need to modify Django to recognize and read this new attribute. In core-django file: db/models/options.py, roughly at line 22 append ‘list_instances’ to DEFAULT_NAMES:

    DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering',
                 'unique_together', 'permissions', 'get_latest_by',
                 'order_with_respect_to', 'app_label', 'db_tablespace',
                 'abstract', 'managed', 'proxy', 'auto_created', 'list_instances')
    

    and in the same file, roughly at line 52, create a default field for this attribute right after the other attributes :

    self.list_instances = False
    

    Step 3:
    We need to pass this information along to the template that generates the index page. In core-django file: contrib/admin/sites.py, inside index() method and inside the “if has_module_perms:” part, add the following code:

    instances = []
    if (model._meta.list_instances == True):
        instances = model_admin.queryset(None)
    

    This will create the list of instances to show, but only if the list_instance attribute is set. In the same file, a few lines further down, append these values to the “model_dict” construct.

    model_dict = {
        'name': capfirst(model._meta.verbose_name_plural),
        'admin_url': mark_safe('%s/%s/' % (app_label, model.    __name__.lower())),
        'perms': perms,
        'list_instances':model._meta.list_instances,
        'instances': instances,
    }
    

    Step 4:
    The final step is to modify the template to support this. Either edit the core-django file /contrib/admin/templates/admin/index.html or copy this file to the templates/admin/ directory of your specific app. Add a few lines after the standard code for generating rows to generate the “sub-rows” if applicable. Roughly at line 40, right between “/tr>” and “{% endfor %}”:

    {% if model.list_instances %}
        {% for instance in model.instances %}
        <tr>
            <td colspan="2" style="padding-left: 2em;">{{ instance }}</td>
            {% if model.perms.change %}
                <td><a href="{{ model.admin_url }}{{ instance.id }}/" class="changelink">{% trans 'Change' %}</a></td>
            {% else %}
                <td>&nbsp;</td>
            {% endif %}
        </tr>
        {% endfor %}
    {% endif %}
    

    This will cause the item to be listed with the name generated by the unicode() method in the model.

    Step 5:
    Lo and behold! It should look something like this:

    enter image description here

    Edit:
    Optional Step 6:
    If you want the instance names to be clickable too, just change the template (index.html) and replace:

    <td colspan="2" style="padding-left: 2em;">{{ instance }}</td>
    

    with:

    <td colspan="2" style="padding-left: 2em;">        
        {% if model.perms.change %}            
            <a href="{{ model.admin_url }}{{ instance.id}}">{{ instance }}</a>
        {% else %}
            {{ instance }}
        {% endif %}
    </td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some of my models, Django-admin, in the index of the model's objects, instead
in the django admin, in any app model, the diplay data (datagrid o view
I use django admin for my users to add their Model objects, as you
I am new to the Django framework. On Django's admin index page I'd like
I'm trying to customize the Django Admin. models.py ============= class Question(models.Model): poll = models.ForeignKey(Poll)
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
I could translate Django Admin except a model label because I don't know how
I am setting up DJango admin to make a model editable. On the same
I'm trying to add features to Django 1.2 admin's main page. I've been playing

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.