首页 > 其他 > 详细

a little summary of Django

时间:2014-11-21 12:28:37      阅读:262      评论:0      收藏:0      [点我收藏+]

url routing mechanism

bubuko.com,布布扣

url name/namespace

We can name a url pattern in urls.py, and reference this name to generate a url in other places. This ensures no hard-coded url. Read the django tutorial for details. (search "Removing hardcoded URLs in templates")

ORM

concept: schema migration

Each time data model is changed, django can generate a migration to record this change and apply it to the database schema.

Suppose two developers are working on the same django project, they have theire own local databases and own test data in dbs.

1. One day, A changed a table schema, and submits his codes into git.

2. B pulls down the newest codes, generate migrations, apply migrations to his own database.

3. This way, B‘s test data is not affected. Without schema migrations, B has to do data migration himself:

    export test data=>drop old table=>create table using new schema=>import test data

Read the django tutorial for details. (search "Creating models")

project and app

referenced from django tutorial:

What’s the difference between a project and an app? An app is a Web application that does something – e.g., a Weblog system, a database of public records or a simple poll app. A project is a collection of configuration and apps for a particular Web site. A project can contain multiple apps. An app can be in multiple projects.

 

a little summary of Django

原文:http://www.cnblogs.com/linghuaichong/p/4112429.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!