Questions tagged [django-media]

1

votes
0

answer
52

Views

Django: Accessing user-uploaded files in view

I have the following question: I have a listview that lists a number of user uploaded PDF files. I am creating a method that Zips them all in a .zip file and emails them (when a button is clicked). I have the following question: I am currently working locally on test data, but on our production set...
Jasper
1

votes
0

answer
74

Views

Server MEDIA (profile pic users) on Django with DEBUG = False

I was deployng my project to Heroku and set up the DEBUG option to False. Until that, all was working ok. But, now, I can't server the user profile images. I want to server only with the Django, not with Apache or Nginx. I know that it's not the best option, but I don't need the best way to do this,...
Joao Lucas
1

votes
0

answer
371

Views

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 I want to add another MEDIA_URL & MEDIA_ROOT to serve...
Rishabh Chaudhary
1

votes
2

answer
300

Views

How to refer to MEDIA_URL from settings.py in models.py?

I know that it is maybe not the most beautiful thing to partialy deling with view in model, but for now I would like to solve my problem this way. in my models.py for one class I define: def admin_image(self): return '' % self.thumbnail.photo admin_image.allow_tags = True BUT I would like that inste...
andilabs
1

votes
1

answer
1.8k

Views

Apache django and static and media file serving

I have a django project that I finally managed to serve using apache. I wanted to be very simple so although my test server was serving /media and static, I didn't include them in my site.conf file. I wanted first to check if deployment works and then have apache serve static files. But, to be hones...
Apostolos
1

votes
1

answer
351

Views

How to define inline Javascript to be rendered for a Django form/widget/admin?

It is well documented how to add an external ressource file to be included by a page containing a Django form (or widget, or admin): defining a nested Media class with js or css members listing the approriate files. This has the effect of adding include directive in the section, of the form: Now, w...
Ad N
1

votes
1

answer
0

Views

Using upload_to with STATICFILES_DIRS

Is it necessary to appoint MEDIA_ROOT, if indicated STATICFILES_DIRS? This issue arose when loading images - upload_to formed using MEDIA_ROOT and ignores STATICFILES_DIRS. If actually did not necessarily how to use upload_to with STATICFILES_DIRS?
I159
1

votes
1

answer
0

Views

django thumbnail img url does not correctly rendered in html

This is HTML code piece that in my template: {%load thumbnail%} And in my settings.py MEDIA_URL='http://url.com/static/' And this is the rendered state of HTML: the problem is: in the rendered html, img url does not valid. Trailing slash is missing between 'static' and 'photodir'. How is that happen...
Sencer H.
1

votes
1

answer
354

Views

How to Scale images in Django

Background: I have to upload images from users. Problem: The images need to be re-sized so that I don't end up with huge images on my disk. This re-sizing should happen just after the image is saved. I have checked the following code Django Snippet for image scaling But couldn't use it directly, a...
Akash Deshpande
1

votes
2

answer
326

Views

django-mediagenerator CSS error

I'm using django-generator and it has been working rather well. However, on some of my machines it seems to have stopped translating url values inside CSS files. On some pages the CSS files will look like this: background-image: url('../img/bg_icongray.png'); And on some of them they will look like...
Goro
1

votes
1

answer
1.1k

Views

Django - Displaying video with jwplayer

I am currently trying to display a video on a website using jwplayer. The view for the page is def video(request): return render_to_response('video_player/video.html', context_instance=RequestContext(request) And the html template being used contains this in the head: And this in the body: Loading t...
CR_Chuck_Norris
1

votes
2

answer
750

Views

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 conclusion of the tests. What is the best way to accom...
Alex Rothberg
1

votes
1

answer
1.1k

Views

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 xxxxxxxxxx; location = /favicon.ico {access_log off; log_not_found of...
Tyler Bell
1

votes
2

answer
1.7k

Views

Why is django not serving my media files?

In my settings.py, ROOT_PATH = os.path.dirname(__file__) #STATICFILES_DIRS = STATIC_ROOT = os.path.join(ROOT_PATH, 'static') MEDIA_ROOT = os.path.join(ROOT_PATH, 'media') STATIC_URL = '/static/' MEDIA_URL = '/media/ in my template, This doesnot work in development, it returns a 404 'GET /media/resta...
Suziemac Tani
5

votes
2

answer
1.9k

Views

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 handles the media served from MEDIA_ROOT. Make sure...
Yannick Berthoud
4

votes
1

answer
3k

Views

Django media URL not found

I'm running into a strange issue,hope some where else some one can had faced the same problem.My problem which is like, the stored media in django application are not able to serve through MEDIA_ROOT URL.When I tried to get list of media files that are saved in my application using URL myhost/media...
Ramakrishna
5

votes
2

answer
1.2k

Views

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 = '' AWS_S3_SECRET_ACCESS_KEY = '' AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STOR...
Soham Shirgaonkar
1

votes
1

answer
681

Views

django media_root not working

I'm using django 1.6 in my settings I have this, which works fine, STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static/'), ) but the moment I add: `MEDIA_ROOT = os.path.join(BASE_DIR, 'media/'), I get a error while rendering a template: 'tuple' does not support the buffer interface problem code:...
Reed Jones
12

votes
3

answer
2.9k

Views

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 because the one suggested there isn't correct i thin...
Apostolos
2

votes
2

answer
1.4k

Views

Django file browser doesn't work

I have installed Django file browser and added grappelli and filebrowser to my installed apps. And did every thing said in documention but when I browse http://127.0.0.1:8000/admin/filebrowser/ I got 404 page not found error. What's the problem? I configured my media settings like this: # Media file...
Hamid FzM
2

votes
1

answer
329

Views

How to externalize Django's Media Data and Serve it to the Frontend

i'm building a restful web service with Django as the backend and am currently concerned with scaling. I want to have an architecure like this: http://www.djangobook.com/en/2.0/_images/scaling-4.png where i can just start up more django instances on high load. My Problem is that i don't know how to...
Jonas Kreusch
1

votes
2

answer
599

Views

Django 1.9: Unable to see uploaded photos

I have some photos uploaded but I was unable to see photos in temeplates My template {% extends 'base.html' %} {% load staticfiles %} {% block content %} {{ object.title }} {% if object.productimage_set.count > 0 %} {% for img in object.productimage_set.all %} {{ img.image.file }} {{ img.image.url }...
spidy
2

votes
1

answer
513

Views

Why does Dajaxice and Dajax uses MEDIAL_URL?

In Dajaxice's installation documentation, it says to set DAJAXICE_MEDIA_PREFIX in settings.py. Later that value is retrieved in the urls.py. In Dajax's installation documentation (which is 2 years old), it says to load the static file like this: Why is it using MEDIA_URL? Shouldn't it be using STATI...
hobbes3
1

votes
1

answer
663

Views

Django not serving media files if I check for settings.DEBUG

This serves the media files correctly: urlpatterns = [ ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) This doesn't serve the media files: from django.conf import settings from django.conf.urls.static import static urlpatterns = [ ... ] if settings.DEBUG: urlpatterns + static(...
2

votes
1

answer
620

Views

Django FilePathField doesn't work with relative path

There is a model Language. Language objects creates Admin through Django-admin. They have to choose from dropdown menu appropriate flag file. The problem is that there is not flag to choice when I deploy project. Since static files are being collected before deploy, I tried to set this path: flag =...
Milano Slesarik
14

votes
3

answer
10.9k

Views

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 file http://localhost:8000/media/items/1a39246c-4160-4cb2-a842-12a1ffd7...
ᚔ ZenOut ᚔ
4

votes
1

answer
3.2k

Views

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 problem is that I can only open files that are within...
aus_lacy
3

votes
2

answer
2.3k

Views

Django nginx admin media

I am currently testing moving from Apache mod_wsgi to Nginx and FastCGI I have prepared the whole installation and currently testing it on a CentOS 5.4 box that runs Django 1.1.2 In my old Apache configuration I had and alias setup for /media/ and also one called /mediaadmin/ Which is displayed belo...
ApPeL
2

votes
1

answer
552

Views

django template doesn't load image uploaded in ImageField properly

i know this question have been brought up a lot of times,but i have tried a lot of different things,not working add.i belive i might have forget to add something silly in my code,just cant figure out what.below is the code of my heading model: class Heading(models.Model): category = models.ForeignKe...
ashish
2

votes
1

answer
945

Views

django - can't see the uploaded media files from apache

I have two different directory for both media and static. And as I upload the files through the local server (localhost:8000), I can see the uploaded images both by the local server and the apache server. However, when I upload it with apache(localhost), I can't see them. I can only see the static....
Robin
3

votes
1

answer
1.2k

Views

django 1.10 media images don't show

I have had django media images working in an existing django 1.7 project by adding the following to site urls.py: urlpatterns = patters( url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), ) This url structure doesn't work in django 1.10...
Atma
15

votes
1

answer
2.3k

Views

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 = '/static/' STATIC_ROOT = 'C:/Users/Sak/mpro/feat/st...
WutWut
2

votes
0

answer
929

Views

Using Amazon S3 with Heroku Django to store image uploads

I have a Django project deployed to Heroku. Locally, it works fine. However, there is a problem in production: the image files uploaded by the admin cannot be found and displayed. The error message is: Failed to load resource: the server responded with a status of 404 (Not Found) and the URL that th...
user3025403
1

votes
3

answer
787

Views

Django: Include Media (css/js) in Class-Based Views

I am updating old django code from method-based views to class-based views. I know how to include media (css/js) in forms via the Media class How can I use the media class if my class based view does not contain any forms?
guettli
2

votes
1

answer
962

Views

Uploading image from Imagefield in django

I am new to Django.I have the following code on my html file: {% load staticfiles %} {% csrf_token %} Submit {{file}} and my views.py for the above code is: if request.method == 'POST': if 'file' in request.POST: f = request.POST['file'] a = MyUser(email='[email protected]', date_of_birth=date.today()) a....
chaitanya90
2

votes
1

answer
460

Views

Images not displaying in Django 1.8

In Django 1.8, I can upload images and they are saved on the path that they should, but when I add the path to template, the images are not displaying. I GET 200 http code for them in terminal server. Here are the relevant parts in settings.py: BASE_DIR = os.path.dirname(os.path.dirname(os.path.absp...
Jand
5

votes
3

answer
2.8k

Views

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 a valid tag library: Template library adminmedia no...
numerah
4

votes
1

answer
2.5k

Views

django admin static files stopped working after upgrade to 1.4

Setting up static files in django has always been a nightmare to me. When it comes to dealing with django static content I get depressed and feel dumb and stupid. I never really cared about getting admin media files served as static ones since I barely use admin interface and there is no impact on p...
abolotnov
1

votes
0

answer
60

Views

Uploading images in Django, hopefully a step-by-step guide?

OK, so I must totally be missing something here... For clarification this is with Django 1.9.7 My model has a field: prop_image = models.ImageField(upload_to=settings.MEDIA_ROOT, null = True, blank = True, max_length=500) I have imported settings, so I don't think the problem is here. That said, my...
user3684314
6

votes
4

answer
6.2k

Views

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 = 'http://localhost:80' ADMIN_MEDIA_PREFIX = '/media/admin/' There is no 'ad...
StanM

View additional questions