Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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 ###
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #django #add #media
ADD COMMENT
Topic
Name
2+2 =