首页 > 移动平台 > 详细

Instant Django 1.5 Application Development Starter

时间:2014-05-07 20:01:45      阅读:479      评论:0      收藏:0      [点我收藏+]
  1. Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  2. Model: The application data
  3. View: which data is presented
  4. Template: How the data is presented
  5. A project is just a collection of settings organized in a defined folder structure to run an instance of Django and they can be auto generated using a Django-admin command offered by the Django package.
  6. The Django development server: python manage.py runserver
  7. The server runs by default on port 8000 and on the default local host IP 127.0.0.01. you can change this by passing the port as the first argument of the runserver command.
  8. Each one of the Django apps included by default needs at least one database table that will be created when we run a Django management command called syncdb.
  9. A Django app is just a Python package with a certain structure located somewhere in your Python path.
  10. The models essentially represented the database layout with some additional metadata.
  11. The first thing that you should note is that each model is represented by a class that is a subclass of Django.db.models.Model.  the class variables in the models represent the database field.
  12. Each field is an istance of the Field class and tells Django what kind of data each field holds. Each field type can be easily understood by looking at the class names.
  13. The name of each field instance is the name that you will use in your Python code to reference the field as well as the column name in your database.
  14. Syncdb command an be called as many times as you like, it will only create the tables that do not exist in the database.
  15.  In Django, a view is just a Python function that accepts a request object as the first parameter and returns a valid HttpResponse Object.
  16. When a Django page is requested the engine looks at the ROOT_URLCONF variable in the settings.py file to know which module is responsible for the routing in this module. Django expects to find a variable called urlpatterns, which is a sequence of tuples with following format: (regular expression, Python callback function [, optional directory])
  17. Django starts matching the requested URL against each regular expression in the list, and as soon as it finds one that matches it calls the callback Python function by passing an HttpRequest object as the first argument.
  18. HttpRequest.method: A string representing the HTTP method used in the request. This is guaranteed to be uppercase.
  19. HttpRequest.GET: a dictionary-like object containing all given HTTP GET parameters
  20. HttpRequest.POST: a dictionary-like object containing all given HTTP POST parameters
  21. HttpRequest.META: a standard dictionary Python dictionary containing all available HTTP headers.
  22. HttpRequest.user: A Django.contrib.auth.models.User object representing the currently logged-in user. If the user isn‘t currently logged in, the user object will be set to an instance of Django.contrib.auth.models.AnonymousUser
  23. HttpRequest.session: a readable-and-writable dictionary-like object that represents the current session. This is only available if your Django installation has session support activated.

Instant Django 1.5 Application Development Starter,布布扣,bubuko.com

Instant Django 1.5 Application Development Starter

原文:http://www.cnblogs.com/bluescorpio/p/3709643.html

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