目录
1. Pycharm安装以及创建python项目
pycharm installed and create python project(python version 3.9)
2. 查看python是否安装成功以及当前版本
check python version
(venv) (base) MacBook-Air pythonwebproject % python --version
Python 3.9.6
3. pip 更新至最新版本
python -m pip install --upgrade pip
Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (21.3.1)
Collecting pip
Using cached pip-23.0.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.3.1
Uninstalling pip-21.3.1:
Successfully uninstalled pip-21.3.1
Successfully installed pip-23.0.1
4.安装django
install django
(venv) (base) MacBook-Air pythonwebproject % pip install django
Collecting django
Collecting sqlparse>=0.3.1
Using cached sqlparse-0.4.3-py3-none-any.whl (42 kB)
Collecting asgiref<4,>=3.6.0
Using cached asgiref-3.6.0-py3-none-any.whl (23 kB)
Installing collected packages: sqlparse, asgiref, django
Successfully installed asgiref-3.6.0 django-4.2 sqlparse-0.4.3
WARNING: You are using pip version 21.3.1; however, version 23.0.1 is available.
5. django-admin 版本查看
(venv) (base) MacBook-Air pythonwebproject % django-admin --version
4.2
6. django-admin 命令查看
(venv) (base) MacBook-Air pythonwebproject % django-admin
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
optimizemigration
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).
7. django-admin 创建项目并启动
(venv) (base) MacBook-Air pythonwebproject % django-admin startproject webproject
(venv) (base) MacBook-Air pythonwebproject % python webproject/manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 18 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.
April 05, 2023 - 08:25:58
Django version 4.2, using settings 'webproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.