Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

managing media in django

#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'
Comment

django add 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 ###
Comment

managing media in django

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)
Comment

media django

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)

Comment

PREVIOUS NEXT
Code Example
Python :: python get majority of list 
Python :: tick labels vertical matplotlib 
Python :: how to save a png seaborn pandas 
Python :: how to create dataframe in python 
Python :: dataframe copy 
Python :: python time now other timezone 
Python :: cv2 draw box 
Python :: python check if there is internet 
Python :: python convert png to jpg 
Python :: find the item with the maximum number of occurrences in a list in Python 
Python :: how to print image with cv2 
Python :: how to install pygame in python 3.8 
Python :: check string similarity python 
Python :: check if image is empty opencv python 
Python :: How to print list without for loop python 
Python :: python function to print random number 
Python :: discord.py mute 
Python :: matplotlib add space between subplots 
Python :: load custom font pygame 
Python :: python access index in for loop 
Python :: mean squared error python 
Python :: pandas determine percentage of nans in column 
Python :: find all text in site python 
Python :: python dns pip 
Python :: python blender select object by name 
Python :: pyton read text file 
Python :: pygame fullscreen 
Python :: pandas dataframe convert nan to string 
Python :: python deep copy of a dictionary 
Python :: openpyxl font 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =