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.

(未完待续)

相关推荐
m4Rk_25 分钟前
【论文阅读】Agent 记忆机制(151):DUNE——让源事实更新沿依赖图传播到派生记忆
论文阅读·人工智能·学习·开源·github
qq_2813174736 分钟前
Kubernetes面试题学习笔记
笔记·学习·kubernetes
叼烟扛炮1 小时前
[LangGraph] 学习笔记(050):自纠正 RAG,检索之后先问一句「这材料用得上吗」
前端·笔记·学习
这里是北京1 小时前
GitHub仓库推荐:Obsidian Skills,让AI把项目笔记组织成可追溯的知识图
笔记·github
BK贝壳3 小时前
浮点值也能挂进混合数组:bool-hybrid-array 的 FloatHybridArray 构造、下标与追加本机实测
开发语言·数据结构·python·性能优化·numpy
钱栈up12 小时前
长安汽车把海外年销钉在100万辆,2030年要翻到200万——出海从故事变成基建
爬虫·python·数据分析
kitsch0x9712 小时前
技术学习_Cowrie 蜜罐的响应机制
学习
富贵儿99812 小时前
NL2SQL 实践手记 03:让模型决定下一步——把 Workflow 改造成 SQL Agent
数据库·python·sql·ai·自然语言处理·langchain
九蝶科技12 小时前
运费分摊的二开实现:BigDecimal 精确分摊 + 尾差补齐 + 暂估调整
开发语言·python
kyrie_sakura13 小时前
大模型学习32 --大模型微调3 -- 分布式训练算法
分布式·学习·算法