Python入门到放弃系列六

本文是Python入门者对Django框架的学习笔记,涵盖了从创建项目到实现Web应用的全过程,包括Django的基本概念、环境配置、启动项目、连接MySQL数据库、表单查询等功能。通过对Django-helloworld的实践,详细介绍了模型、视图、模板和URL的使用,以及后台管理和模板系统的理解。
摘要由CSDN通过智能技术生成

目录

第二部分 项目-Web应用

第十八章 Django 入门

Django-helloworld

Django-懵逼学习中

Idea配置启动python-django项目

测试编写逻辑代码

连接mysql数据库

表单查询功能


第二部分 项目-Web应用

第十八章 Django 入门

Django-helloworld

第一块搞什么虚拟环境?

大致了解了下是为了不同版本冲突或者维护独立可运行环境的一个控制手段。

https://blog.csdn.net/godot06/article/details/81079064

hello-world版本,先无脑按照书上来一遍看看效果,增加下性趣。

ruishens-MacBook-Pro:python_work ruishen$ mkdir learning_log
ruishens-MacBook-Pro:python_work ruishen$ cd learning_log/
ruishens-MacBook-Pro:learning_log ruishen$ ll
total 0
drwxr-xr-x   2 ruishen  staff    64  6 18 15:37 .
drwxr-xr-x  44 ruishen  staff  1408  6 18 15:37 ..
ruishens-MacBook-Pro:learning_log ruishen$ python3 -m venv ll_env
ruishens-MacBook-Pro:learning_log ruishen$  source ll_env/bin/activate
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ❶
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ll
total 0
drwxr-xr-x   3 ruishen  staff    96  6 18 15:42 .
drwxr-xr-x  44 ruishen  staff  1408  6 18 15:37 ..
drwxr-xr-x   6 ruishen  staff   192  6 18 15:42 ll_env
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ source ll_env/bin/activate
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ pip3 install Django
Collecting Django
  Downloading Django-3.2.4-py3-none-any.whl (7.9 MB)
     |████████████████████████████████| 7.9 MB 25.0 MB/s 
Collecting pytz
  Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 34.4 MB/s 
Collecting sqlparse>=0.2.2
  Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 1.8 MB/s 
Collecting asgiref<4,>=3.3.2
  Downloading asgiref-3.3.4-py3-none-any.whl (22 kB)
Installing collected packages: sqlparse, pytz, asgiref, Django
Successfully installed Django-3.2.4 asgiref-3.3.4 pytz-2021.1 sqlparse-0.4.1
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the '/Users/ruishen/python_work/learning_log/ll_env/bin/python3 -m pip install --upgrade pip' command.
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ python3 -m pip install --upgrade pip
Requirement already satisfied: pip in ./ll_env/lib/python3.9/site-packages (21.1.1)
Collecting pip
  Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-21.1.2
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ django-admin.py startproject learning_log .
/Users/ruishen/python_work/learning_log/ll_env/bin/django-admin.py:17: RemovedInDjango40Warning: django-admin.py is deprecated in favor of django-admin.
  warnings.warn(
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ❷ll
-bash: ❷ll: command not found
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ls
learning_log	ll_env		manage.py
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ll
total 8
drwxr-xr-x   5 ruishen  staff   160  6 18 15:43 .
drwxr-xr-x  44 ruishen  staff  1408  6 18 15:37 ..
drwxr-xr-x   7 ruishen  staff   224  6 18 15:43 learning_log
drwxr-xr-x   6 ruishen  staff   192  6 18 15:42 ll_env
-rwxr-xr-x   1 ruishen  staff   668  6 18 15:43 manage.py
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ls learning_log/
__init__.py	asgi.py		settings.py	urls.py		wsgi.py
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ python3 manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
(ll_env) ruishens-MacBook-Pro:learning_log ruishen$ ls
db.sqlite3	learning_log	ll_env		manage.py
(ll_env) ruishen
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值