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

managin media 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_ROOT = BASE_DIR / 'media'
MEDIA_URL = '/media/'
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 isprime 
Python :: Local to ISO 8601 with TimeZone information (Python 3): 
Python :: convert mb to gb python 
Python :: Tkinter button icons 
Python :: show battery of my laptop python 
Python :: pytorch use multiple gpu 
Python :: draw a circle in python turtle 
Python :: real time crypto prices python 
Python :: get columns containing string 
Python :: how to input comma separated int values in python 
Python :: python - show repeted values in a column 
Python :: boxplot pandas 
Python :: python replace 0 in series 
Python :: display Surface quit 
Python :: Delete the node at a given position 2 in a linked list and return a reference to the head node. The head is at position 0. The list may be empty after you delete the node. In that case, return a null value. 
Python :: location of last row dataframe 
Python :: python requests with login 
Python :: check nan values in a np array 
Python :: python max value of list of tuples 
Python :: adjust size of plot 
Python :: hello world py 
Python :: right angle triangle in python 
Python :: beautifulsoup find_all by id 
Python :: how to create a new virtualenv 
Python :: adding numbers using python function 
Python :: python weekday 
Python :: how to reference a file in python 
Python :: pandas save one row 
Python :: python getting class name 
Python :: all the positions of a letter occurrences in a string python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =