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.

(未完待续)

相关推荐
weelinking7 小时前
【2026】08_Claude与版本控制:Git协作技巧
数据库·人工智能·git·python·数据挖掘·交互·cloudera
凉、介11 小时前
Armv8-A virtualization 笔记 (二)
笔记·学习·嵌入式·arm·gic
智者知已应修善业12 小时前
【ICL8038芯片正弦波三角波方波发生器电路】2024-1-5
驱动开发·经验分享·笔记·硬件架构·硬件工程
JoneBB12 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
scan72412 小时前
智能体多个工具调用
python
2401_8676239812 小时前
CSS Flex布局中如何设置子元素间距_掌握gap属性的现代用法
jvm·数据库·python
探序基因13 小时前
身高与基因的关系
笔记
即使再小的船也能远航13 小时前
【Python】安装
开发语言·python
weixin_4217252613 小时前
Linux 编程语言全解析:C、C++、Python、Go、Rust 谁更强?
linux·python·go·c·编程语言
没有梦想的咸鱼185-1037-166313 小时前
AI-Python机器学习、深度学习核心技术与前沿应用及OpenClaw、Hermes自动化编程
人工智能·python·深度学习·机器学习·chatgpt·数据挖掘·数据分析