Questions tagged [django-media]
237 questions
293
votes
18 answers
Django MEDIA_URL and MEDIA_ROOT
I'm trying to upload an image via the Django admin and then view that image either in a page on the frontend or just via a URL.
Note this is all on my local machine.
My settings are as follows:
MEDIA_ROOT = '/home/dan/mysite/media/'
MEDIA_URL =…

Dan
- 3,041
- 2
- 17
- 9
59
votes
6 answers
Page not found 404 Django media files
I am able to upload the files to media folder( '/peaceroot/www/media/') that I have set up in settings.py as below
MEDIA_ROOT = '/peaceroot/www/media/'
MEDIA_URL = '/media/'
But through admin I tried to access the uploaded image…

madhu131313
- 7,003
- 7
- 40
- 53
20
votes
5 answers
Adding css class to field on validation error in django
I am using Django's modelform and its really good. How can I highlight the actual text box (e.g. border:red ) if there is a validation error associated with it. Basically what i want is to add a class (error) if there is a validation error to a…

Myth
- 1,562
- 5
- 15
- 25
20
votes
1 answer
Serving Media files during deployment in django 1.8
I am trying to deploy my django app on heroku. All the static files are served by whitenoise and are migrated successfully. But how do I get my media files that are uploaded using ImageField to display during production.
my settings.py
STATIC_URL =…

WutWut
- 1,204
- 2
- 17
- 31
12
votes
1 answer
Django/Nginx - Error 403 Forbidden when serving media files over some size
When user uploads image, it is stored in media folder inside project directory. The problem is that when they want to see it on the website, nginx return 403 Forbidden error for images over approximately 3 Mb.
I set nginx.conf client_max_body_size…

Milano
- 18,048
- 37
- 153
- 353
12
votes
3 answers
Django serving media files (user uploaded files ) in openshift
I have successfully deployed my Django project in openshift. But I need to be able to serve files that are uploaded by users. I user MEDIA_ROOT and MEDIA_URL for that. I followed this tutorial here, but nothing happened. I had to change MEDIA_ROOT…

Apostolos
- 7,763
- 17
- 80
- 150
11
votes
2 answers
Django Storages using s3boto ignoring MEDIA_URL
I am trying to use django-storages with s3boto in my app and trying to serve media and static files from s3.
I have the following settings in my settings file:
AWS_STORAGE_BUCKET_NAME = ''
AWS_S3_ACCESS_KEY_ID =…

sshirgao
- 291
- 3
- 9
9
votes
2 answers
Django and Nginx X-accel-redirect
I have been fumbling around with trying to protect Django's media files with no luck so far! I am simply trying to make it where ONLY admin users can access the media folder. Here is my Nginx file.
server {
listen 80;
server_name…

Tyler Bell
- 837
- 10
- 30
9
votes
1 answer
Opening a data file from the media directory in Django
I have an application that allows for users to upload CSV files with data which is then graphed and displayed to the user. These files are saved as media within my media folder. In my graph view however I need to open the file and process it. My…

alacy
- 4,972
- 8
- 30
- 47
6
votes
4 answers
Django cannot find my media files (on development server)
The media is currently on my local development machine.
My MEDIA_ROOT, MEDIA_URL, ADMIN_MEDIA_PREFIX and are specified as below:
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
MEDIA_URL = '/media/'
SITE_URL =…

StanM
- 827
- 4
- 12
- 33
5
votes
3 answers
how to serve media files in django app nginx server?
I am testing my django app in production mode (debug=false) using nginx, gunicorn, postgresql.
Though I am able to render static files, I am unable to access files stored in 'media' folder.
In my settings.py following are the variables set:
…

Simran
- 593
- 1
- 14
- 37
5
votes
1 answer
Setting multiple MEDIA_URL & MEDIA_ROOT in django
I've set Static and Media root as well as url's in my django app, as follows:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
MEDIA_URL = '/crl/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'config/crl/')
It is working great, but…

Cool Breeze
- 738
- 2
- 10
- 26
5
votes
2 answers
S3BotoStorage and Unit Testing
I am using the storages.backends.s3boto.S3BotoStorage for my DEFAULT_FILE_STORAGE in a Django project.
Ideally I would like to either use the default FileSystemStorage during unit tests or perhaps create a temporary bucket that is deleted on the…

Alex Rothberg
- 10,243
- 13
- 60
- 120
5
votes
2 answers
Attempted access to '/media/uploads/
I've problem with upload method on the admin/ urls:
In my settings:
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
# URL that…

Yannick Berthoud
- 59
- 2
- 5
5
votes
3 answers
conversion from django 1.4 to 1.5 errors
i an doing exactly the same Django admin datepicker calendar and clock img
and i am suffering with the same problem but it was working perfectly fine with django 1.4 but when i updated it to django 1.5 it is giving me this error
'adminmedia' is not…

numerah
- 498
- 7
- 29