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.

(未完待续)

相关推荐
weixin_5689960618 小时前
Cgo 中正确设置 C 结构体回调函数指针的完整方案
jvm·数据库·python
Jun62618 小时前
【RV1103】AD4115实现8通道ADC采样,MQTT数据传输,1K采样率
linux·python
SHARK_pssm18 小时前
【数据结构——顺序表】
c语言·数据结构·经验分享·笔记
LiAo_1996_Y18 小时前
mysql如何限制特定存储过程执行权限_MySQL存储过程安全访问
jvm·数据库·python
knight_9___18 小时前
LLM工具调用面试篇1
开发语言·人工智能·python·面试·agent
2601_9561394218 小时前
快消品品牌全案公司哪家强
大数据·人工智能·python
源码之家18 小时前
Python股票数据分析与预测系统 大数据项目
大数据·python·机器学习·数据挖掘·数据分析·股票·可视化
甄心爱学习18 小时前
【项目实训(个人5)】
python·github
智者知已应修善业18 小时前
【51单片机ADC-MAX1241/ADC0832驱动】2023-6-6
c++·经验分享·笔记·算法·51单片机
z44247532618 小时前
新买的电脑装哪个HTML函数工具最匹配_开箱即用教程【教程】
jvm·数据库·python