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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:12:33+00:00 2026-05-21T11:12:33+00:00

I’m from a PHP background but have been given a Django project to administer,

  • 0

I’m from a PHP background but have been given a Django project to administer, I’ve brought it over to a new server running Django 1.2.5 (Python2.6) and got it all running as it was on the old one. I have now been tasked with fixing bugs from the old developers. So far so good, but I’ve hit a stumbling block with an ImageField. Essentially a user can have an image logo uploaded (this works). However when a user without a logo edits their details Django throws an error:

ValueError: The 'org_logo' attribute has no file associated with it.

The code snippet that results in the error is:

user = request.user
org = user.organisation
if not checkLogoFile(org):
    org.org_logo = ''
    org.save()

The function checkLogoFile looks like this:

def checkLogoFile(org):
from os.path import exists
path = org.org_logo.path
if path:
    file_name = path.split('/')[-1]
    return exists(settings.MEDIA_ROOT+'logo/'+file_name)
return False

The way I understand it the if checkLogoFile returns false then the org_logo value will be a zero length string. If the org_logo contains a path then that is returned. As mentioned this fails when an image logo is not present but works when one is. :-/

Any pointers would be very helpful as I’ve scoured Google and so far am not getting anywhere.

  • 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-21T11:12:34+00:00Added an answer on May 21, 2026 at 11:12 am

    Fixing the problem:

    def checkLogoFile(org):
       from os.path import exists
       path = org.org_logo.path if org.org_logo else None
       if path:
           file_name = path.split('/')[-1]
           return exists(settings.MEDIA_ROOT+'logo/'+file_name)
       return False
    

    But anyway, I don’t really get why complicate this checking this way. Why not just

    def checkLogoFile(org):
       from os.path import exists
       path = org.org_logo.path if org.org_logo else None
       return path and exists(path)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have text I am displaying in SIlverlight that is coming from a CMS
I have a bunch of posts stored in text files formatted in yaml/textile (from
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I have a JSP page retrieving data and when single or double quotes are
I am trying to loop through a bunch of documents I have to put

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.