Django By Example - 学习笔记

Chapter 1 Building A Blog Application

1. Installing Django

Installing Python3 on Mac:

bash 复制代码
pip3 install python3

Creating Virtual Environment:

bash 复制代码
python3 -m venv .venv

Installing Django with pip3:

bash 复制代码
pip3 install django

Creating your first project:

bash 复制代码
django-admin startproject blog

Let's take a look at the generated project structure:

These files as follows:

  • manage.py

    A command-line utility to interact with your project. It is a thin wrapper around the django-admin.py tool.

  • blog/

    Your project directory consists of the following files:

    • init.py

      An empty file that tells Python to treat the blog directory as a Python module.

    • settings.py

      Settings and configuration for your project. Contains initial default settings.

    • urls.py

      The place where your URL patterns live. Each URL defines here is mapped to a view.

    • wigs.py

      Configuration to run your project as a WSGI application.

Note that:
The generated settings.py file includes a basic configuration to use a SQLite database and a list of Django applications that are added to your project by default. We need to create the tables in the database for the initial applications.

Click New Terminal and run the following commands:

python 复制代码
cd blog
python 复制代码
python3 manage.py migrate

The tables for the initial applications have been created in the database.

(未完待续)

相关推荐
AOwhisky10 小时前
MySQL 学习笔记(第六期):MySQL 备份与恢复
运维·数据库·笔记·学习·mysql·云计算
辣椒思密达10 小时前
Python公开数据采集实战:如何解决请求高频拦截与Session会话中断问题
开发语言·python
_李小白10 小时前
【android opencv学习笔记】Day 32:直线检测之霍夫变换
android·opencv·学习
Albart57510 小时前
Python 实战教程:用 30 分钟学会解决真实问题
开发语言·python
2301_7736436210 小时前
ceph池
开发语言·ceph·python
华山沦贱10 小时前
open62541 V1.5.4版对C++ Builder支持的bug
笔记
极客笔记Jack11 小时前
Scanpy AnnData 对象深度解析:高效操作数据结构的10个技巧
python
稷下元歌11 小时前
七天学会plc 加机器视觉完整笔记:S7-1200 数据类型、存储区与寻址方式(I/Q/M/DB 详解)。
网络·数据库·笔记
颜酱11 小时前
LangChain调用向量模型,存入向量数据库
python·langchain
提子拌饭13311 小时前
Column 嵌套布局:多级 Column 实现复杂纵向结构——鸿蒙 HarmonyOS ArkTS 原生学习应用
学习·华为·harmonyos·鸿蒙·鸿蒙系统