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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:51:24+00:00 2026-05-26T12:51:24+00:00

This is killing me! I’m using django-filebrowser, and I want to create a gallery

  • 0

This is killing me!

I’m using django-filebrowser, and I want to create a gallery app that leverages it’s upload capabilities to manage images.

I have a Gallery model that allows the user to select or create a directory on the server, and upload files to that folder to appear in the gallery. I want to automatically trawl the directory that the user has uploaded images to and selected, and then automatically create Image instances for each image in the folder.

class Gallery(model.Models):
    gallerydirectory = FileBrowserField(...)
    title = ...
    description ...

class Image(model.Models):
    image_field = models.ImageField()

The problem is that FileBrowser represents images differently to Django, but I want to use DJango ImageFields as I can then use other apps (sorl thumbnails) on the template end.

I have all the data necessary for the file i.e. filename, path etc, I just can’t get Django to create an instance of an ImageField, without actually uploading the image again. I simply want to populate it.

I have seen another thread here which suggests the following:

for image in filebrowser_image_objects_list:
    f = File(open('path-to-file-on-server','r'))
    i = Image()
    i.image_field('filename.png',f.read())

but this is giving me a:

SuspiciousOperation error
Attempted access to '/filename.png' denied 

which suggests that the path isn’t being read correctly. I’ve printed the attributes of the File Object, and it is opening the correct image, it just isn’t getting passed on to the ImageField

Help would be greately appreciated!

UPDATE

I’ve given up trying to get this work as it’s just too messy. The problem I had above was that I had set the upload_field of the ImageField to ‘/’ and it had gone unnoticed meaning that the file was being written to ‘/something.png’.

I’ve modified it so that the Image is now using a FileBrowserField as well instead of an ImageField.

  • 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-26T12:51:25+00:00Added an answer on May 26, 2026 at 12:51 pm

    I’m marking this as answered, as this is the correct way to do this:

    from django.core.files import File
    
    image_model.image_field('path', File().read())
    

    Programmatically saving image to Django ImageField

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

Sidebar

Related Questions

This one is killing me. I'm trying to make a simple console app that
This has been killing me - I have a massive file that I need
Killing the processs while obtaining this information would be fine.
This may not really sound hard to do but it is currently killing me.
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
This is KILLING me! I have a view. in the .h file i do
This is killing me. I've read these: http://msdn.microsoft.com/en-us/library/athddy89(v=VS.80).aspx http://msdn.microsoft.com/en-us/library/2baksw0z(v=VS.80).aspx But I don't see how
ok desperation. This is killing me.. I totally do not understand MapKit at all..
This one is killing me... I'm learning to develop SOAP servers in PHP at
This problem is killing my productivity. The Emacs Starter Kit automatically enables hl-line, which

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.