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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:24:14+00:00 2026-05-13T15:24:14+00:00

I am trying to have the pictures I upload in the Django admin panel

  • 0

I am trying to have the pictures I upload in the Django admin panel to show up as thumbnails instead of the path. I have sorl installed and can make thumbnails that show up in my views.

I have found 2 snippets (http://www.djangosnippets.org/snippets/579/ and http://www.djangosnippets.org/snippets/934/) that I have tried to implement, but both attempts have failed because of the meager documentation and my as yet shallow understanding of the Django framework.

Could someone please provide a dumbed-down step-by-step guide of how I can get this to work?

Thanks!

  • 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-13T15:24:14+00:00Added an answer on May 13, 2026 at 3:24 pm

    Yeah ๐Ÿ™‚ I can ๐Ÿ˜‰

    First you need to create a custom template tag that handles the thumbnail:

    from django.template import Library
    from django.utils.safestring import mark_safe
    from django.contrib.admin.templatetags.admin_list import result_headers
    
    register = Library()
    
    def results(cl):
        out = []
        for item in cl.result_list:
            url = cl.url_for_result(item)
            code = '<a href="%(url)s">%(img)s</a> <div><a href="%(url)s">%(title)s</a></div>' % {
                'url': url,
                'img': item.preview.thumbnail_tag,
                'title': item.title,
            }
            out.append(mark_safe(code))
    
        return out
    
    def gallery_result_list(cl):    
        return {'cl': cl,
                'result_headers': list(result_headers(cl)),
                'results': results(cl)}
    result_list = register.inclusion_tag("admin/app_name/model/change_list_results.html")(gallery_result_list)
    

    where item.preview.thumbnail_tag is the thumnail created by sorl ๐Ÿ™‚
    [I got the original code from the default template tag]

    Second you need to create a template for your model (that uses the new custom template tag), it must be in this directory schema:
    templates_dir/admin/app_name/model/change_list.html

    and have the following code:

    {% extends "admin/change_list.html" %}
    {% load adminmedia admin_list my_admin_tags i18n %}
    
    {% block result_list %}
        {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
        {% gallery_result_list cl %}
        {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
    {% endblock %}
    

    as you can see in the tag function you need to create one more template (called change_list_result.html) for display the image correctly:

    <style>
    td.page { text-align: center; }
    td.page a { font-weight: bold; }
    </style>
    {% if results %}
    <table cellspacing="0">
    <tbody>
    <tr>
    {% for result in results %}
        <td class="page">
            {{ result }}
        </td>
        {% if forloop.counter|divisibleby:3 %}
    </tr><tr>
        {% endif %}
    {% endfor %}
    </tr>
    </tbody>
    </table>
    {% endif %}
    

    so at the end you’ll have 3 files:

    1. templates_dir/admin/app_name/model_name/change_list.html
    2. templates_dir/admin/app_name/model_name/change_list_result.html
    3. your_project/app_name/templatetags/my_admin_tags.py

    and, of course, templatetags must be added to INSTALLED_APP in settings ๐Ÿ˜‰

    this is all ๐Ÿ˜‰ Hope this can be helpful.

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

Sidebar

Related Questions

I'm trying to get my website to upload video's and pictures. As I have
I'm trying to get my website to upload video's and pictures. As I have
I have a product form that users can upload 5 pictures simultaneously. Everything is
I'm building an app where each user can have multiple profiles. Users can upload
I have a PHP script where a user can upload an image. This image
We are trying to use persits upload code to upload pictures to 2 different
I have a upload field where people can upload a image. I'd like to
I am trying to upload an image using django and following a tutorial from
I am trying to allow users to upload pictures to the server. I am
I am trying to make an old Django project run again. Update #1: I

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.