码迷,mamicode.com
首页 > 其他好文 > 详细

a little summary of Django

时间:2014-11-21 12:30:07      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   ar   color   os   sp   

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

标签:des   style   blog   http   io   ar   color   os   sp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!