TypeError: serve() got an unexpected keyword argument 'document_root'

Question:

my problem Here the image/file that the user uploaded aren’t being displayed(They are being saved though!!) when I run the site using Terminal I get an error message on Terminal TypeError: serve() got an unexpected keyword argument 'document_root' but the site runs just fine. when I open my site on chrome it displays name of the image/file and only a symbol of an image/file but i want it to display the image/file it self not a symbol.

Setting.py:

STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

MEDIA_URL = '/media/'

( This only some part of the urls.py)

urls.py:

from django.urls import path
from django.conf import settings
from django.conf.urls.static import static

urlpatterns += static(settings.MEDIA_URL, documnet_root=settings.MEDIA_ROOT)

( This is also some part of the html file that displays the image)

file.html

{% if model.image %}
    <image src="{{model.image.url}}">
{% endif %}
Asked By: Shad0w

||

Answers:

(moving comment to answer)

Just a typo:

documnet_root should be document_root

Answered By: Mike67

mine was upper uppercase for argument document

urlpatterns += static(settings.MEDIA_URL, Document_root=settings.MEDIA_ROOT)

this fixed my problem

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Answered By: Noel Langat
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.