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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:50:15+00:00 2026-05-27T11:50:15+00:00

I want a view to return image data. so something along the lines of

  • 0

I want a view to return image data. so something along the lines of

return HttpResponse(image_data, mimetype=”image/png”)

I know I can do a file.read() to get the image data, but because the image is small (like 1×1 px) I want to just store it as a string object (or whatever object I can copy and paste in my code). This way, I save myself the disk lookup everytime the view is hit.

How do i go about this? I’m sure this is easy, I’m just not sure what terms to use for search.

p.s. I know that one does not normally serve images this way with Django.

  • 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-27T11:50:15+00:00Added an answer on May 27, 2026 at 11:50 am

    Here is a simple example from the django-openid project

    def logo(request):
        return HttpResponse(
            OPENID_LOGO_BASE_64.decode('base64'), content_type='image/gif'
        )
        # Logo from http://openid.net/login-bg.gif
        # Embedded here for convenience; you should serve this as a static file
        OPENID_LOGO_BASE_64 = """
        R0lGODlhEAAQAMQAAO3t7eHh4srKyvz8/P5pDP9rENLS0v/28P/17tXV1dHEvPDw8M3Nzfn5+d3d
        3f5jA97Syvnv6MfLzcfHx/1mCPx4Kc/S1Pf189C+tP+xgv/k1N3OxfHy9NLV1/39/f///yH5BAAA
        AAAALAAAAAAQABAAAAVq4CeOZGme6KhlSDoexdO6H0IUR+otwUYRkMDCUwIYJhLFTyGZJACAwQcg
        EAQ4kVuEE2AIGAOPQQAQwXCfS8KQGAwMjIYIUSi03B7iJ+AcnmclHg4TAh0QDzIpCw4WGBUZeikD
        Fzk0lpcjIQA7
        """
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For Example: Let's say that I want to return a view that displays a
We've got a bunch of data the users may want to view windows of
In my code, I want to view all data from a CSV in table
I'm a new iphone developer, question is I want to know the sym.data 's
I want to create user profile with image. That user can upload his photo,
I have a form in which user inputs its data along with its image.
I want to write a custom view engine that returns custom text (like coma
i want a view with UITabBAr at The bottom with some buttons+Navigation controller on
I want to view the nfs shares that are exported on a windows server
Using Eclipse I want to view the source code for a core Java class

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.