相关文章推荐
憨厚的长颈鹿  ·  Android ...·  2 年前    · 
腼腆的人字拖  ·  Oracle ...·  2 年前    · 
痴情的豆腐  ·  oracle update语句 ...·  2 年前    · 
火星上的小熊猫  ·  scRNA-Seq | SCENIC ...·  2 年前    · 
憨厚的墨镜  ·  【SEED Labs ...·  2 年前    · 

上传在Github上的虚拟环境中设置的Django项目

1 人关注

我刚刚开始学习Django,在项目的 "拷贝 "方面遇到了一些问题。 我有两台电脑,我想用两台电脑进行开发。当我学习PHP的时候(那时我甚至不知道如何使用Github),我所要做的就是在两台电脑上设置一个webserver,通过Google Drive上传整个文件(从一台电脑),然后从另一台电脑下载。

然而,在我看来,Django有些不同,因为它是一个框架,在开始一个项目之前有很多设置(包括虚拟环境;我正在按照Youtube的教程学习,它说如果我使用virtualenv会更好一些)。我认为仅仅把整个项目文件夹下载到另一台电脑上是不行的。

目前,我已经把整个虚拟环境文件夹上传到Github上。

So, to list my questions,

  • When downloading it on the other computer, should I setup the virtual environment on that computer and then download the folder?...
  • Is there any way that I can only sync or commit the files that has been changed in the project automatically? (That is, i have to change many files in django projects(views, urls, settings... etc) but it would be hard to remember all the files that i have changed and then seperately commit those ones)
  • 希望得到任何帮助。

    python
    django
    git
    heesub ahn
    heesub ahn
    发布于 2014-12-13
    2 个回答
    Sourabh
    Sourabh
    发布于 2014-12-14
    已采纳
    0 人赞同

    Edit: Consider using pipenv

    我建议你也安装 virtualenvwrapper ( here )。virtualenvwrapper将除了你的项目之外的所有文件保存在另一个位置,所以你的项目目录只包含你的文件,你可以安全地使用 git add --all

    在其安装后,请做。

    $ mkdir my-project; cd my-project
    $ mkvirtualenv my-env-name
    $ pip install django <more-good-stuff>
    $ pip freeze > requirements.txt
    $ git init; git add --all; git commit -m "Initial Commit"
    ... push to github ...
    

    现在到另一台机器上,安装virtualenvvirtualenvwrapper

    $ git clone <url> my-project; cd my-project 
    $ mkvirtualenv my-env-name
    $ pip install -r requirements.txt
    ... continue your work, commit and push push and win at life :D