Python3.8安裝配置Django環(huán)境(上)
【本節(jié)知識點】:
配置開發(fā)環(huán)境:Python3.8 + Django
查看Python版本
安裝django又沾、查看版本
安裝pymysql
新建django項目
測試django服務器
1、CMD查看python版本
C:\Users\Administrator>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
2汰寓、CMD查看pip版本
C:\Users\Administrator>pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
debug Show information useful for debugging.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to
WARNING, ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
(a)bort.
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the
certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output
C:\Users\Administrator>Python3.8安裝配置Djan
3雕什、pip 安裝Django缠俺,默認Django3
C:\Users\Administrator>pip install django
Collecting django
Using cached https://files.pythonhosted.org/packages/12/68/8c125da33aaf0942add5095a7a2a8e064b3812d598e9fb5aca9957872d71/Django-3.0.4-py3-none-any.whl
Collecting sqlparse>=0.2.2 (from django)
Using cached https://files.pythonhosted.org/packages/85/ee/6e821932f413a5c4b76be9c5936e313e4fc626b33f16e027866e1d60f588/sqlparse-0.3.1-py2.py3-none-any.whl
Collecting asgiref~=3.2 (from django)
Using cached https://files.pythonhosted.org/packages/68/00/25013f7310a56d17e1ab6fd885d5c1f216b7123b550d295c93f8e29d372a/asgiref-3.2.7-py2.py3-none-any.whl
Collecting pytz (from django)
Using cached https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl
Installing collected packages: sqlparse, asgiref, pytz, django
Successfully installed asgiref-3.2.7 django-3.0.4 pytz-2019.3 sqlparse-0.3.1
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
升級pip
python -m pip install --upgrade pip
4、查看Django版本
C:\Users\Administrator>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(3, 0, 4, 'final', 0)
>>>
5贷岸、安裝mysql
pip install pymysql
6壹士、查看mysql版本
7、建立Django文件夾并進入偿警,
C:\Users\Administrator>mkdir django
C:\Users\Administrator>cd django
8躏救、開始一個django項目
C:\Users\Administrator\django>django-admin.py startproject hellodjango
C:\Users\Administrator\django>cd hellodjango
C:\Users\Administrator\django\hellodjango>dir
驅動器 C 中的卷沒有標簽。
卷的序列號是 BA47-1B36
C:\Users\Administrator\django\hellodjango 的目錄
2020-03-27 15:51 <DIR> .
2020-03-27 15:51 <DIR> ..
2020-03-27 15:51 <DIR> hellodjango
2020-03-27 15:51 652 manage.py
1 個文件 652 字節(jié)
3 個目錄 45,728,935,936 可用字節(jié)
9、運行服務器盒使,測試Django項目
C:\Users\Administrator\django\hellodjango>manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 17 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.
March 27, 2020 - 15:51:31
Django version 3.0.4, using settings 'hellodjango.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
10崩掘、使用地址訪問http://127.0.0.1:8000/Django項目
![Django.jpg](https://upload-images.jianshu.io/upload_images/7506896-5b4cf58aca9036a0.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
[27/Mar/2020 15:51:39] "GET / HTTP/1.1" 200 16351
[27/Mar/2020 15:51:40] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
Not Found: /favicon.ico
[27/Mar/2020 15:51:40] "GET /favicon.ico HTTP/1.1" 404 1977
[27/Mar/2020 15:51:40] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
[27/Mar/2020 15:51:40] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
[27/Mar/2020 15:51:40] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184