Django simple configuration of the static media

 

# In Django application file folder, often will find two folders: static, media; static called static folder to hold the same file CSS, JavaScript, and other Web site logo; In contrast, the media say media folder to store the user to upload pictures.

 

1、static

= STATIC_URL ' / static / '   # static file alias (relative path) and the absolute path 
STATICFILES_DIRS = ( 
    the os.path.join (base_dir, ' app01 / static ' ), 
)
View Code

 

2、media

# The settings.py configuration item: 
of MEDIA_ROOT it the os.path.join = (base_dir, ' Media ' ) 


# configure route 
from django.views.static Import serve
 from django.conf Import Settings 

URL (R & lt ' ^ Media / (P <? . path> *) ' , serve, { ' DOCUMENT_ROOT ' : settings.MEDIA_ROOT})
View Code

 

Guess you like

Origin www.cnblogs.com/pdun/p/11291141.html