环境设置

在生产环境和开发环境都使用相同database engine

原因:

1 没办法用本地的数据cover实际的生产环境

2 不同的数据库有不同的字段限制

使用虚拟环境和包管理工具 pip + virtualenv

Pip pip

is a tool that fetches Python packages from the Python Package Index and its mirrors. It is used
to manage and install Python packages. It’s like easy_install but has more features, the key feature
being support for virtualenv.

Virtualenvvirtualenv

is a tool for creating isolated Python environments for maintaining package dependencies.
It’s great for situations where you’re working on more than one project at a time, and where there are
clashes between the version numbers of different libraries that your projects use.

py3.3+ python有自带的 venv

python3 -m venv /path/to/new/virtual/environment

ps virtualenvwrapper virtualenvwrapper , virtualenvwrapper-win

使用版本控制 Git

控制代碼的改變迭代

Version control systems are also known as revision control or source control. Whenever you work on
any Django project, you should use a version control system to keep track of your code changes

保持环境的一致

不一致的原因

Operating system differences. 
操作系统不一致
    If we’re developing on a Mac or on Windows, and if our site is deployed on Ubuntu Linux, then there are huge differences between how our Django project
    works locally and how it works in production.
    
Python setup differences. 
python设置不同
    Let’s face it, many developers and sysadmins don’t even know which version of Python they have running locally, although no one will admit it. Why? Because setting
    up Python properly and understanding your setup completely is hard.
    
Developer-to-developer differences. 
开发者
    On large development teams, a lot of time can be wasted trying to debug differences between one developer’s setup and another’s.

最好的方法是 使用Docker

优点:

Docker 像是在虚拟机中进行开发,但是更轻量级

Docker containers share the host OS but have their own isolated process and memory space

    For example, if our development laptops run OS X (or Windows, or Centos, etc) but a project’s
    configuration is Ubuntu-specific, we can use Docker via Docker Compose to quickly get a virtual
    Ubuntu development environment set up locally, complete with all the packages and setup configurations needed for the project

缺点:

更复杂

机器压力更大
Buy me a 肥仔水!