Django

gae-django
Articles
Resources
Frameworks
Why django

Basic
Installation
Deployment
Database
Model
Testing

What does django community call a request handler?

Django's request handlers, called views, are just Python functions.

What is generic view?

One of Django's greatest strengths is its adherence to the DRY principle (don't repeat yourself). The architects of Django recognized several common code patterns and have created various shortcuts to simplify repetitive tasks and common patterns. To this end, Django has the concept of generic views, which not only map results to templates, but also simplify the development process by abstracting a lot of recurring code.

In our case, the generic view direct_to_template is used in order to render the fetched Greeting objects and the form. Also, it takes care of adding useful extra variables like the current request and user to the view. This step can be configured via so-called context processors which let users add, modify, or delete variables that eventually get sent to the template. In general, generic views provide functionality for common tasks like creating/editing or displaying model instances.

What is the alternative? You would have to create custom views for all user output, giving yourself and your app a high probability of repeating yourself. Also note that direct_to_template is the simplest available generic view. You'll save a lot more time (and code) with more advanced generic views like object_list that takes care of paginating a query and displaying current results pages — you really don't want to be repeatedly writing such common functionality by hand.

What is a view and what is a template?

A view is a python function. It is responsible for choosing the right template. A template contains mainly HTML code, mixed with some template constructs which are necessary to implement conditional logic or looping logic if necessary.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License