Hi, add these two lines to your settings.py file MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
after that in your base urls.py (a file along with settings.py) add the following url: from django.conf.urls.static import static from django.conf import settings if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS) Jeff Williams <jeff99willi...@gmail.com> در تاریخ چهارشنبه ۲۱ نوامبر ۲۰۱۸ ساعت ۴:۳۸ نوشت: > Hey Akash, > I did figure out the enctype="multipart/form-data" issue (I had that for a > while but figured it out). My files are loading.....they just aren't > displaying. > > I just loaded an image using the Admin interface as you suggested (I > hadn't thought of trying that) and the load is working. The URL and path > are still (relatively) the same: > http://127.0.0.1:8000/media/documents/reciper_rK1KS3j.jpg > D:\DjangoStuff\familyrecipies\media\documents\reciper_rK1KS3j.jpg > > Still getting this when I try to display. > Page not found (404) > Request Method: GET > Request URL: http://127.0.0.1:8000/media/documents/reciper_rK1KS3j.jpg > > Using the URLconf defined in familyrecipies.urls, Django tried these URL > patterns, in this order: > > 1. admin/ > 2. oldgrub/ > 3. > 4. accounts/ > > The current path, media/documents/reciper_rK1KS3j.jpg, didn't match any > of these. > > You're seeing this error because you have DEBUG = True in your Django > settings file. Change that to False, and Django will display a standard > 404 page. > > I think I mentioned before that I took another picture-upload project, > built it, and made it work (which it did). > When I took the relevant parts into my own app....it stopped working :-(. > > On Tue, Nov 20, 2018 at 3:06 AM Akash Purandare <akashp1...@gmail.com> > wrote: > >> Hey Jeff >> >> It is completely alright to try until we find a solution to this. >> I quote from the Django Documentation: >> Note that request.FILES >> <https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.HttpRequest.FILES> >> will >> only contain data if the request method was POST and the <form> that >> posted the request has the attribute enctype="multipart/form-data". >> Otherwise, request.FILES will be empty. >> >> Can you ensure that the particular requirements are fulfilled? >> >> Also, I would like to ask you to try to upload a file from the Django >> admin panel and tell me if it is working. If not, can you send me the URL >> and the uploaded path of the Admin panel uploaded file? >> >> Regards >> Akash Purandare >> >> On Sunday, November 18, 2018 at 8:48:04 PM UTC+5:30, Jeff Williams wrote: >> >>> Hi All, >>> I'm new to django, so sorry if this is a newbie issue. >>> >>> I've managed to upload an ImageField....but when I try to display it in >>> my template using object.pic.url...the URL I'm getting back is missing my >>> project name from the URL and the pic is not loading. >>> >>> Specifically I'm getting >>> http://127.0.0.1:8000/media/media/56288852934__75FACD12-1711-4655-96D5-716198FE10B7.JPG >>> back.....and >>> I need >>> >>> http://127.0.0.1:8000/*oldgrub* >>> /media/media/56288852934__75FACD12-1711-4655-96D5-716198FE10B7.JPG >>> >>> back to have it work. >>> >>> What am I missing? I've poured over my configs. >>> Jeff >>> >> -- >> 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+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@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/7a1672c8-0f53-41f3-88c0-e3d7a70e7ae3%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/7a1672c8-0f53-41f3-88c0-e3d7a70e7ae3%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@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/CAMgbqCdBfiKTUS38XtwsmZ1ETp6cJ04G8CyiFPne6rOfbc2oog%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAMgbqCdBfiKTUS38XtwsmZ1ETp6cJ04G8CyiFPne6rOfbc2oog%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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/CAJjGCEN-NwJJksZqKK1xw5ozO%2BAUah6MophQrcZjN-ex6nBKQQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.