Django 框架的安裝及使用

1.下載安裝 Pythonpython

https://www.python.org/downlo...django

> py --version
Python 3.9.1

2.建立一個名爲 my-project 的虛擬環境並激活測試

> py -m venv my-project
# 修改 PowerShell 對於腳本的執行策略
> set-executionpolicy remotesigned
# 激活虛擬環境
> my-project\Scripts\activate.bat

3.安裝 Djangoui

> py -m pip install Django
> django-admin --version
3.1.4

4.建立一個名爲 mysite 的項目url

> django-admin startproject mysite

5.查看建立後的目錄結構code

mysite/
    manage.py
    mysite/
        __init__.py
        asgi.py
        settings.py
        urls.py
        wsgi.py

6.啓動服務orm

> python manage.py runserver 8000

Watching for file changes with StatReloader
Performing system checks...
...
Django version 3.1.4, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

7.訪問 http://127.0.0.1:8000/ 測試服務運行狀況server

相關文章
相關標籤/搜索