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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:10:40+00:00 2026-06-12T21:10:40+00:00

I can succesfully save a file via Django admin in one of my models

  • 0

I can succesfully save a file via Django admin in one of my models but cannot open the file aftewards. Here is my model:

class Answer (models.Model):
    answer = models.CharField(max_length=1000)
    attach_file = models.FileField(upload_to='Attachments', blank=True)

I have not touched the settings file and to my understanding it should use defaults values:

MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = ''

I registered the model in the admin.py and I was able to Browse a file and save it. When trying to open that file, i get:

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/businessui/answer/1/Attachments/outlook.png/
answer object with primary key u'1/Attachments/outlook.png' does not exist.

Could someone point out what I am missing here to be able to also open saved files locally on my dev machine?

  • 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-12T21:10:43+00:00Added an answer on June 12, 2026 at 9:10 pm

    In reference to @Sawwy’s comment on @RicardoCarmo’s answer. I post as an answer for the formatting.

    Here’s what I use in my main url conf:

    if getattr(settings, 'DEBUG', False) or getattr(settings, 'DEBUG_MEDIA', False):
        media_url = getattr(settings, 'MEDIA_URL', '/media/').lstrip('/')
        urlpatterns = patterns('',
            url(r'^%s(?P<path>.*)$' % (media_url,), 'django.views.static.serve', {
                'document_root': settings.MEDIA_ROOT
            }),
        ) + urlpatterns
    

    Note that in a production environment, your media files should be served up by the web server and those requests should not reach Django. That is why it’s qualified with if DEBUG or DEBUG_MEDIA.

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

Sidebar

Related Questions

i can succesfully run crawl command via cygwin on windows xp. and i can
I wanted to design a simple site where one person can upload a file,
I'm trying to save to databse a pdf file generated by itextsharp. But, I
I need to save a file after a succesfully checkout. So I'm using the
I have two models, one called Notes and one called Comments. Comments can be
i have succesfully installed OpenCv & Qt in Ubuntu..i can debug and run some
Symptom: Some users cannot successfully POST, most can successfully POST. When the error occurs,
How can I unlock or delete a file that is in use, so that
I'm trying to save a map with points overlayed to a png file use
I'm trying to create a form where users can save their progress. I have

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.