Writing your first django app, part 2

this tutorial begins where Tutorial 1 left off.We'll setup the database, create your first model, and get a quick introduction to Django's automatically-generated admin site.
这篇教程从教程1,我们会配置自己的数据库,创造你的第一个模型,开始一个快捷的django自动生成管理员站点。

database setup

if you wish yo use another databse install the approprite database bindings ans change the following keys in DATABASE 'default itemto match your database connection setting:

ENGINE : django.db.backends.mysql

NAME : The name of your database.

The migrate command looks at the INSTALLED_APPS setting and creates any nessary database tables according to the database setings in your mysite/settings.py fiel and database migrations shipped with the app. You'll see a message for each migration it applies. If you're interested, run the commadn-line client for your database ans type

migrate查看INSTALLED_APPS设置并根据这个mysite/setting.py文件中的数据库设置创建任何必要的数据库表,数据库的迁移还会跟踪应用的变化

minimalists : 极简主义者

a model is a single, definitive source of truth about your data.It contains the essential fields ans behaviors of the data you're storing.

项目和应用之间有什么不同呢,应用是一个web应用程序,他完成具体的事项,比如一个博客系统一个存储工作档案的数据库或者一个简单的头片应用。项目是一个特性网站的相关配置和应用的集合。一个项目可以包含多个应用。一个应用可以应用到多个项目中去。


CarlBenjamin
1 声望3 粉丝

My name is Carl Benjamin. Let's Fly away for the coding life.