django,建立第一個django專案並且成功執行
主要還是介紹在win10上面的操作過程
主要用的技術:python3.8;django2
編輯器/ide:vscode、sublime——text、powershell、web
建立虛擬環境
python開發,虛擬環境第一步。
PS F:\demo> virtualenv env --no-site-packages
Using base prefix 'd:\\program files\\python\\python38-32'
New python executable in F:\demo\env\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
PS F:\demo>
在後面的步驟中每次都需要先進入虛擬環境:
PS F:\demo> .\env\Scripts\activate
建立django專案
pip下載django2.0.3:
(env) PS F:\demo> pip install django==2.0.3
Collecting django==2.0.3
Using cached https://files.pythonhosted.org/packages/3d/81/7e6cf5cb6f0f333946b5d3ee22e17c3c3f329d3bfeb86943a2a3cd861092/Django-2.0.3-py3-none-any.whl
Collecting pytz
Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
|██████ | 92kB 267kB/s eta
···
Installing collected packages: pytz, django
Successfully installed django-2.0.3 pytz-2019.3
建立一個django_blog專案:
(env) PS F:\demo> django-admin startproject django_blog
執行專案:
(env) PS F:\demo> cd .\django_blog\
(env) PS F:\demo\django_blog> python .\manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
December 23, 2019 - 07:08:03
Django version 2.0.3, using settings 'django_blog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
我們訪問http://127.0.0.1:8000/ 可以發現django專案順利的執行起來了。
瀏覽器還是推薦使用谷歌或者火狐。
本作品採用《CC 協議》,轉載必須註明作者和本文連結
文章來源首發於我的部落格Stray_Camel(^U^)ノ~YO