Django virtualenv布局 [英] Django virtualenv layout

查看:119
本文介绍了Django virtualenv布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对django很新。我使用virtualenv只是一个关于项目布局的基本问题。当我们创建virtualenv并安装所有依赖项-django等时,是否需要将我的目录切换到virtualenv,然后在那里创建一个项目?或者我需要在virtualenv之外创建我的项目。如果这是一个非常基本的问题,我很抱歉。

解决方案

不,创建虚拟环境的目录是完全独立的你不会去创建你的django项目。



事实上,你通常会把你所有的虚拟环境放在一个单独的目录中;对我来说,我把它们放在 $ HOME / work / .envs (注意默认),所以我的工作流程变成:

  $ virtualenv $ HOME / work / .envs / new_env 
$ source $ HOME / work / .envs / new_env / bin / activate
(new_env)$ pip install django
(new_env)$ cd〜/ projects
(new_env)/ projects $ django-admin。 py startproject atestproj

所以你看,你实际上没有对虚拟环境目录做任何事情;它完全由 virtualenv pip 管理。



virtualenvwrapper 项目通过管理您的虚拟环境使您更轻松一个中央位置。


I am very new to django. I just have a very basic question about project layout using virtualenv. When we create virtualenv and install all the dependencies-django etc, do I need to switch my directory to the virtualenv and then create a project there? Or do I need to create my project outside of virtualenv. I apologize if it is a very basic question.

解决方案

No, the directory where you create the virtual environment is completely separate and is not where you would go and create your django project.

In fact, you would usually put all your virtual environments in a separate directory; for me I put them in $HOME/work/.envs (note the ., this makes the directory hidden by default), so then my workflow becomes:

$ virtualenv $HOME/work/.envs/new_env
$ source $HOME/work/.envs/new_env/bin/activate
(new_env)$ pip install django
(new_env)$ cd ~/projects
(new_env)/projects$ django-admin.py startproject atestproj

So you see, you don't actually do anything with the virtual environment directory; it is completely managed by virtualenv and pip.

The virtualenvwrapper project makes this easier by managing your virtual environments in a central location.

这篇关于Django virtualenv布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆