Media files

23 views
Skip to first unread message

Cody Davis

unread,
Jun 19, 2018, 7:18:40 AM6/19/18
to Django users
Hey everyone. New to Django here i apologize is this question is already answered somewhere.

So i have read the FileField docs and 50 times. I have defined my MEDIA_URL and MEDIA_ROOT. When i upload an image through the admin, i can see the file goes where i directed it to inside of Django. If i try and go into admin, to the user that uploaded the image and click the link to open it, i get an error saying the ID doesn’t exist, maybe i deleted it?
I searched the internet up and down until i found the solution. I had to map a URL to urls.py to open it. My problem is i have zero understanding why. Like I’ve mentioned i tried finding anything about having to MAP the url to my image and can’t find documentation. Can anyone explain what I’ve done wrong? Or where this is at in the docs? It’s not in the field models that’s for sure.

Akshay Gaur

unread,
Jun 19, 2018, 11:06:02 AM6/19/18
to Django users
Maybe there is an issue with the way django is serving the docs. Try the following:
  • in your base urls.py, add the following: 
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

In case this doesn't work, would it be possible for you to post the relevant part of the code and some screenshots?

Hope this helps.
Akshay

Cody “theultimatecasual” Davis

unread,
Jun 19, 2018, 5:38:00 PM6/19/18
to django...@googlegroups.com
Well i have that. My problem really is i can’t find anywhere in the docs that says i need to add that. I’m really just looking for the documentation on it. 

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/08ac90aa-c3a7-45fb-8af8-27252e52c8f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason

unread,
Jun 19, 2018, 7:56:54 PM6/19/18
to Django users

Cody “theultimatecasual” Davis

unread,
Jun 19, 2018, 9:21:49 PM6/19/18
to django...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages