Django MEDIA_URL is not working

Asked

Viewed 388 times

1

Until yesterday it was running smoothly the route /media/ in DEV, and I went to make a production deploy and a production dump for my environment to match, and started giving this problem. I also had to add new features of various branchs, so something happened that I am not able to identify. Currently my settings are this way:

py.:

if settings.DEBUG:
    # static files (images, css, javascript, etc.)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

py Settings.

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
STATIC_ROOT = os.path.join(BASE_DIR, "public")
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    os.path.join(BASE_DIR, 'media'),
)

But I get a 302 every time I upload an image or file that’s on the media. And worse, it redirects to the main route /

[23/Aug/2017 14:55:35] "GET /media/product/teste.png HTTP/1.1" 302 0
[23/Aug/2017 14:55:35] "GET / HTTP/1.1" 200 16764
  • Is your production environment the same as DEV? I mean, they both run LINUX/Windows?

  • Dude I solved my problem, it was a little shit I took on a route I created to work with static pages. She was overwriting all the other haha routes. I will close the question. Thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.