如何在django开发服务器depyloment中共享文件夹

时间:2015-10-09 12:32:19

标签: python django ubuntu

我创建了一个虚拟环境并安装了最新的django。接下来我创建一个项目。现在,我想要做的是在项目目录中创建一个文件夹,以便在我进行开发服务器部署时使用浏览器访问其内容。我怎样才能做到这一点?我需要为此创建一个应用程序吗?

1 个答案:

答案 0 :(得分:1)

我认为你的意思是,是为了提供静态文件:

https://docs.djangoproject.com/en/1.8/howto/static-files

基本上您需要做的是在{productfamily -> {productfeature, productfeature}, -> {productfeature1, productfeature1}, -> {productfeature1synonym, productfeature1}, -> {productfeature1synonym2, productfeature1} } 中定义2个设置:

  • STATICFILES_DIRS(您希望从哪个dir提供这些文件)
  • STATIC_URL(您希望此文件夹映射到哪个网址?)

例如:

settings.py

现在您可以访问localhost:8000 / static / image.jpg

访问/var/www/static/image.jpg