Questions tagged [django-media]

237 questions
1
vote
2 answers

show images that are uploaded by user in django

I have a page which allows a user to upload an image and that image is stored by the models.py file in the {{MEDIA_ROOT}}/image/image1.jpg i want to display this image through a html image tag on another web page My html code snippet is
Hitesh D
  • 99
  • 2
  • 8
1
vote
1 answer

How can i get django to process media files on production?

How can i get django to process media files on production when DEBUG = False on heroku server? I know that it’s better not to do this and that this will lead to a loss of performance, but my application is used only by me and my cat, so I don't…
lleviy
  • 406
  • 5
  • 16
1
vote
2 answers

Why cannot I see the image file in django?

I tried to load an image file, but it didn't work. I uploaded the image file by admin. Thanks for the help! here is my code in urls.py path('main/archive//', views.loadphoto, name='loadphoto'), in views.py def loadphoto(request,…
dh Jung
  • 13
  • 3
1
vote
0 answers

Django: Media for Views?

I know the Media class for django forms. I like the simple way to include JS/CSS: class CalendarWidget(forms.TextInput): class Media: css = { 'all': ('pretty.css',) } js = ('animations.js', 'actions.js') Is…
guettli
  • 25,042
  • 81
  • 346
  • 663
1
vote
2 answers

Programmatically saving image to Django ImageField returning 404 in production

I have a Django app where users can upload images and can have a processed version of the images if they want. and the processing function returns the path, so my approach was model2.processed_image = processingfunction(…
1
vote
0 answers

Page not found 404 error when trying to serve media files in Django

I want to display user uploaded images in my template. I can't seem to find what I'm doing wrong. Using Django 2.2 version. I tried what the documentation says (https://docs.djangoproject.com/en/2.2/howto/static-files/) but couldn't find any other…
1
vote
2 answers

I can upload images to specific directory but can't view them in template (Page not found (404))

I am trying to add upload image to admin form in my Django project I found on GitHub. I can upload image to folder my_app(catalog)/media/images/image.png but when I try to call it in the template I can only see that image icon that appears when…
ziggy
  • 11
  • 1
1
vote
3 answers

Incomplete media url in nested serializers

I have a django-rest-api application with models Record, Tag and Weight, where Record and Tag have many-to-many relation through the Weight model: # models.py class Tag(models.Model): image = models.ImageField(upload_to='tag_images', null=True,…
1
vote
2 answers

Django media file not found 404

I have a Django blog application wherein while posting a blog, a file can be attached and submit as well. Here is the views.py code: def user_own_blog(request): if request.method == 'POST' and request.FILES['blog_document']: …
Simran
  • 593
  • 1
  • 14
  • 37
1
vote
0 answers

Django Admin MediaOrderConflictWarning

Ever since upgrading to Django 2.1, I am receiving a runtime error /Applications/anaconda3/envs/svod-api-env/lib/python3.6/site-packages/django/forms/widgets.py:126: MediaOrderConflictWarning: Detected duplicate Media files in an opposite…
Annie
  • 45
  • 9
1
vote
0 answers

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…
1
vote
0 answers

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…
Jasper
  • 2,131
  • 6
  • 29
  • 61
1
vote
0 answers

404 when requesting url of saved image in media directory using django rest framework

I am developing a django rest api using the django rest framework. The rest api manages clothing items to be shown in an android application and has a model named Clothing which has an ImageField for showing the clothing item. From the django admin,…
Tom Finet
  • 2,056
  • 6
  • 30
  • 54
1
vote
1 answer

Why is {% load static %} a dependency for {% get_media_prefix %}?

I've been using {% get_media_prefix %} for a very long time. I was explaining this to someone when he pointed this out. Why do I need to declare {% load static %} in order to use it? It even uses in the documentation's example code here. To an…
Shivam Sharma
  • 901
  • 1
  • 6
  • 12
1
vote
3 answers

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
  • 25,042
  • 81
  • 346
  • 663