1. 程式人生 > >Python 程式設計: 從入門到實踐 學習筆記 18

Python 程式設計: 從入門到實踐 學習筆記 18

  1. 為專案新建一個目錄,建立虛擬環境;
    18.1.2 建立虛擬環境
$ mkdir learning_log
$ cd learning_log/
learning_log$ python3 -m venv ll_env
  1. 啟用虛擬環境
    18.1.4 啟用虛擬環境
learning_log$ source ll_env/bin/activate
(ll_env)learning_log$
  1. 安裝 Django
    18.1.5 安裝 Django
(ll_env)learning_log$ pip3 install Django
  1. 在 Django 中建立專案
(ll_env)learning_log$ 
django-admin.py startproject learning_log . (ll_env)learning_log$ l learning_log/ ll_env/ manage.py*
  1. 忽略檔案
    20.2.11 使用 GIT 跟蹤專案檔案

manage.py 所在的資料夾中建立一個名為 .gitignore 的檔案.

(ll_env)learning_log$ touch .gitignore

在這個檔案中輸入如下內容:

.gitignore

ll_env/
__pycache__/
*.sqlite3
  1. 提交專案
(ll_env) henry@G460-Ubuntu
:~/dev/learning_log$ git init Initialized empty Git repository in /home/henry/dev/learning_log/.git/ (ll_env) henry@G460-Ubuntu:~/dev/learning_log$ git add . (ll_env) henry@G460-Ubuntu:~/dev/learning_log$ git commit -m "首次 commit" [master (root-commit) bc1fd91] 首次 commit 6 files changed, 175 insertions(+) create mode 100644
.gitignore create mode 100644 learning_log/__init__.py create mode 100644 learning_log/settings.py create mode 100644 learning_log/urls.py create mode 100644 learning_log/wsgi.py create mode 100755 manage.py (ll_env) henry@G460-Ubuntu:~/dev/learning_log$ git status On branch master nothing to commit, working directory clean
  1. 在 github 上新建專案 learning_log ,將本地專案 push 到 github .
(ll_env)learning_log$ git remote add origin https://github.com/henry199101/learning_log.git
(ll_env)learning_log$ git push -u origin master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 2.57 KiB | 0 bytes/s, done.
Total 9 (delta 0), reused 0 (delta 0)
To https://github.com/henry199101/learning_log.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

一個專案剛開始時,要做的事情:建立&啟用虛擬環境/安裝web框架/.gitignore忽略檔案/push 到github等等,要做的事情,應該就是這麼多,暫時到此為止…