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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:25:28+00:00 2026-06-04T02:25:28+00:00

First time posting so I hope I’m doing this right. I’m creating a custom

  • 0

First time posting so I hope I’m doing this right.

I’m creating a custom admin form in “myapp/admin.py”, and I’m using the line : default_storage.exists('/usr/tmp/somefile.txt').

However, exists() is throwing a SuspiciousOperation exception. I took a look into it and the problem seems to be coming from safe_join(base, *paths) in “_os.py”.

It turns out the base paramenter is being set to '/' and this breaks the following code in safe_join() :

if not normcase(final_path).startswith(normcase(base_path)) \
  or final_path[base_path_len:base_path_len+1] not in ('', sep):
    raise ValueError('The joined path (%s) is located outside of the base '
                     'path component (%s)' % (final_path, base_path))

I don’t run into this problem when I use default_storage.exists() in manage.py shell. Also, I’m using Django 1.4 and Python 2.7.

Any help is appreciated! Thanks in advance!

  • 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-04T02:25:30+00:00Added an answer on June 4, 2026 at 2:25 am

    It sounds to me like something is not set up correctly in your settings.py
    The possible reason you are seeing that SuspiciousOperation exception is because your default_storage.location is set to / root, and I would think having access to the root of your filesystem is definitely suspicious.

    You may want to check that you have set MEDIA_ROOT in your settings.py to something reasonable as a location for storage:
    https://docs.djangoproject.com/en/1.4/ref/settings/#media-root

    It seems that default_storage.location value derives from the MEDIA_ROOT? For me, it is equal to that value. When I try to do default_storage.exists() on a path that lives higher than the location, it raises that exception as well.

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

Sidebar

Related Questions

First time posting in Stack Overflow, hope I'm doing this right. I'm writing an
First time posting on here, so I hope I do this correctly, however I
this is my first time posting my problem here, i hope i get help
first time posting here. I'm using a loop to create 3 buttons, but my
this is my first time posting here, I have a question which I have
That's my first time posting on stackoverflow. I've been finding usefull answers on this
this is my first time posting on StackOverflow but this site is awesome. Thanks
use this website a lot but first time posting. My program creates a number
First time posting here, will try to be succinct. This is a classic 'can't
This is my first time posting to stackoverflow, but these threads have helped me

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.