發表文章

Django 學習筆記 第二堂: 基本指令

  ### Django 版本查詢 user@hostname:~$ python Python 2.7.11+ (default, Apr 17 2016, 14:00:29) [GCC 5.3.1 20160413] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django; >>> print(django.get_version()); 1.9.4 >>> quit Use quit() or Ctrl-D (i.e. EOF) to exit >>> # 路徑查詢 $ python -m site or $ python -c "import sys; print('\n'.join(sys.path))" ###或直接查詢 $ python -m django --version pip workflow 管理 requirement.txt pip freeze 會列出所有被安裝的 python 模組及其版本 $ pip freeze > requirements.txt ###   套件先安裝要求的模組 $ pip install -r  .\requirements.txt

Django 學習筆記 第一堂: 環境建置與框架特色

  安裝 django 環境 # 基本套件安裝 ,先檢查有沒有裝 python3 & pip3 $python3 -V $sudo apt install python3-pip # 已安裝套件查詢 $pip3 list Using Django inside a Python virtual environment Install the tool using  pip3 : $sudo pip3 install virtualenvwrapper # 加入 .bashrc export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 export VIRTUALENVWRAPPER_VIRTUALENV_ARGS=' -p /usr/bin/python3 ' export PROJECT_HOME=$HOME/Devel source /usr/local/bin/virtualenvwrapper.sh # refresh env 變數 $source ~/.bashrc Using a virtual environment Section There are just a few other useful commands that you should know (there are more in the tool documentation, but these are the ones you'll use regularly): deactivate  — Exit out of the current Python virtual environment workon  — List available virtual environments workon name_of_environment  — Activate the specified Python virtual environment rmvirtualenv name_of_environment  — Remove the specified environment. # 新創一個虛擬環境名稱...