Questions tagged [django-media]

237 questions
0
votes
3 answers

Django images not showing up in template

I've spent the whole day trying to find a solution for showing the images in the template but I couldn't find any solution to my case. This is my settings STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,…
Islam Fahmy
  • 139
  • 10
0
votes
1 answer

how to serve a media file in Django?

I have a Django project where I'm trying to create a card with an image that was uploaded by the user. I keep getting a certain error but I have already done every solution and its still coming up. any help would be appreciated. the {{image}}…
Dunham
  • 101
  • 3
0
votes
0 answers

Django App on Azure App Service. How to upload files and view the uploaded files

I had created a Django app in which user can upload files and view it in dashboard. Its working fine in local system but when I deployed it in Azure App Service the file is uploading but can't view the file in dashboard. Its shows no file but i can…
0
votes
2 answers

request media files in django when the debug is false

i tried to set media root and media url in but when the debug is false don't return anything settings.py ... DEBUG = False ALLOWED_HOSTS = [ '127.0.0.1', '0.0.0.0', ... ] ... STATIC_URL = 'static/' STATICFILES_DIRS = [ BASE_DIR /…
user18981192
0
votes
2 answers

Django Picture showing as broken when referenced in template

I am trying to create a settings page for user profiles and I have hit a roadblock. I included a profile image inside of my User model and when trying to reference said ImageField in my profile template the image shows up as broken. Firstly,…
0
votes
0 answers

How to server Django media files on apache2 and docker

I'm Running a django app on apache2 using docker, everything works great but when i try to open an uploaded file ( media file) it says an URL not found error like : physical/path/to/file/filename.jpg doesnt exsits so it converts the url to a…
Ahmed Wagdi
  • 3,913
  • 10
  • 50
  • 116
0
votes
2 answers

Django media url from model

I'm working on a simple blog, I have this model for the blog post: class BlogPost(models.Model): title = models.CharField(max_length=150, unique=True) body = models.TextField() cover_image = models.ImageField(upload_to='blogposts/') …
0
votes
0 answers

Django Static files Page not found (404)

I am trying to create a website using Django and in my models.py I am using Django's ImageField(upload_to=''), but these files are not being uploaded to their location and I don't know why. That file is empty. So I am getting this error Page not…
Jack
  • 460
  • 5
  • 16
0
votes
0 answers

Django wrong imagefield.path

i have a model with an image field like this app_icon = models.ImageField(upload_to='icons/') the project has 'uploads' as media folder, which has subfolders, including 'icons'. The image is correctly uploaded to the 'icons' subfolder but when i…
Michele Candura
  • 109
  • 1
  • 2
  • 6
0
votes
0 answers

Django Static doesn't load but is accessible. NGINX and Docker

I have connected my Django (DRF) to Gunicorn and Nginx and put it all in docker. When I load mysite.com/admin/ it looks bad, just plain text. So it seems like it does not load any static file. However, in Browser Console there are zero…
0
votes
1 answer

Django doesn't load a default picture. I have MEDIA root connected to urls

So I want the imageField to load a default picture when one is not uploaded by user. When I upload something in the imageField form, they end up in the correct folder. When I want it to load a default pic, it simply doesn't show up. I checked…
boryswnr
  • 1
  • 3
0
votes
0 answers

Page not found (404) error after setting media folder django

I am getting Page not found (404) error after I set up the media folder as follows in settings.py: MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' then in urls.py: from django.contrib import admin from django.urls import path from…
corey95
  • 1
  • 1
0
votes
1 answer

Media Files and Static files not Displaying and working in Django

when deployed server then static files not working and media files not diplaying. 404 error here is the urls.py from django.views.static import serve import django from django.contrib import admin from django.urls import path, include from…
0
votes
1 answer

How to make model.ImageField as mandatory in django admin?

I need to make upload image in django admin panel as a mandatory field, is there any possibility? Here what i did: models.py class ContentData(models.Model): title = models.CharField(max_length=100,null = True) description =…
0
votes
0 answers

Display media files with Django

I learn Django and I have a problem with display img in settings I add: MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "moje_media") and in url.py I add static urlpatterns = [ //routing ] + static(settings.MEDIA_URL,…