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

The Archive Base Latest Questions

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

Hey guys i have an issue with an app am trying to develop in

  • 0

Hey guys i have an issue with an app am trying to develop in django. I am trying to show thumbnails in the admin interface but instead it shows the url. Here is what i have in my models.py

from sorl.thumbnail.main import DjangoThumbnail
from django.db import models
from django.contrib.auth.models import User


class Slide(models.Model):

    #Image Fields
    image = models.ImageField(
        upload_to="/srv/www/htdocs/photos/gallery/images/",
        height_field="image_height",
        width_field="image_width"
    )
    image_height = models.PositiveIntegerField(null=True, blank=True, editable=False)
    image_width = models.PositiveIntegerField(null=True, blank=True, editable=False)

    title = models.CharField(max_length=128)
    order = models.PositiveIntegerField(default=0)

    def slide_thumbnail(self, width=300, height=200):
        if self.image:
            thumb = DjangoThumbnail(self.image, (width, height))
            return '{img src="%s" /}' % thumb.absolute_url
        return '{img src="/media/img/admin/icon-no.gif" alt="False"}'
    slide_thumbnail.allow_tags = True

    def __unicode__(self):
        return u'Slide: %s - %sx%s' % (self.title, self.image_height, self.image_width)

And here is what i have in my admin.py

from django.contrib import admin
from models import *
from django.contrib import admin

class SlideAdmin(admin.ModelAdmin):
    list_display = ('title', 'order', 'slide_thumbnail',)
admin.site.register(Slide, SlideAdmin)

I am using django 1.4 on suse 12.1 and running apache as my web server and was trying to follow the tutorial here:

http://www.acedevs.com/blog/2011/07/11/django-admin-list-view-thumbnails/

But instead, I get a url in “slide thumbnail” column instead or an image.
The url i get looks like this

{img      src="/srv/www/htdocs/photos/gallery/images/702362_10200241914757028_37708631_n_jpg_300x200_q85.jpg" /}

Could someone tell me what am doing wrong because it uploads the images well but it doesnt display them

  • 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-16T12:22:38+00:00Added an answer on June 16, 2026 at 12:22 pm

    You should mark the img tag as safe like this:

    from django.utils.safestring import mark_safe
    
    #... your code
    return mark_safe('<img src="%s" />') % thumb.absolute_url
    

    Hope this leads into the right direction.

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

Sidebar

Related Questions

Hey guys I have a little issue here. I have a panel where I
Hey guys I have an admin page that checks if you are admin before
Hey guys I have what should be a simple question, but I am new
hey guys having this really simple problem but cant seem to figure out have
Hey guys another rails issue, Currently have a collection that is line items for
Hey guys I got a weird issue.. I have a datalist that's only loaded
Hey Guys, having an issue with Linq-to-SQL, I am basically doing the following but
Hey guys I have a little issue with a function that retrieves data from
Hey guys, I have a little issue here. I need my users to be
Hey guys so I have a interface where, once a user logs in their

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.