#in base url
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
#in setting
MEDIA_URL='/media/
MEDIA_ROOT=BASE_DIR / 'media'
### add the following lines in Project settings.py ###
MEDIA_URL='/media/'
MEDIA_ROOT=BASE_DIR / 'media'
### add the following lines in Project urls.py ###
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# put here your urls
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
### now once you add another object a media folder will be created ###
### in the base folder and you can use it ###
### remember to add .url when viewing the image in html ###
### Ex. obj.Image_Propertey_Name.url ###
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# ----------------or----------------
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Code Example |
---|
Python :: |
Python :: select a value randomly in a set python |
Python :: |
:: |
:: |
:: hide particular attribute in django admin |
Python :: |
:: |
:: |
:: |
:: wait() in python tkinter |
:: opencv get contours |
:: ImportError: cannot import name ABC |
Python :: |
:: |
:: |
:: |
Python :: drop columnd python |
:: django make migrations |
:: remove duplicate row in df |
:: matplotlib set number of decimal places |
:: |
:: code for making an exe file for python |
:: |
:: |
:: |
:: |
Python :: |
:: |
Python :: getting image from path python |