[django]django 在apache2上部署静态文件如何加载

时间:2022-12-18 23:32:32

 

首先找到apache2的conf文件下的httpd.conf,添加如下信息:

Alias /static/ E:/wamp/Apache24/www/static/ <Directory E:/wamp/Apache24/www/static> Options FollowSymlinks AllowOverride none Require all granted </Directory>

django 工程下setting中对应设置:

# Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/  STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), )