'TypeError: 'module' object is not callable (+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT))

here is my django project's urls.py


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

urlpatterns = [
    path('',views.index,name='home'),
    path('abouts/about/',views.about,name='about'),
    path('abouts/contact/',views.contact,name='contact'),
    path('orders/cart/',views.cart,name='cart'),
    path('shops/dashboard/',views.dashboard,name='dashboard'),
    path('shops/orders/',views.orders,name='orders'),
    path('shops/checkout/',views.checkout,name='checkout'),
] +static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) 

and the part of settings.py where I defined media url and media root

import os
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

STATICFILES_DIRS = [
     BASE_DIR/ 'static',
     
]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')

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

but the server says

ile "C:\Users\ITS\Desktop\e-com\commerce\shop\urls.py", line 15, in <module>
    ] +static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
TypeError: 'module' object is not callable

I do this always but now it showing me this. thanks in advance for helping.



Solution 1:[1]

You could try to replace from django.conf.urls import static to from django.conf.urls.static import staticin your Django project's urls.py. Pay attention to details.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 richardec