CSC/ECE 517 Fall 2014/ch1a 8 os: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 9: Line 9:
=== Object- Relational Mapper ===
=== Object- Relational Mapper ===
Django has its own object relational mapper which eases database access. It facilitates writing of model classes directly in python. Model classes can be defined by sub-classing  [https://docs.djangoproject.com/en/1.7/ref/models/instances/#django.db.models.Model django.db.models.Model]. Each attribute of this class corresponds to a database field. This makes it possible to use an automatically generated database access API.
Django has its own object relational mapper which eases database access. It facilitates writing of model classes directly in python. Model classes can be defined by sub-classing  [https://docs.djangoproject.com/en/1.7/ref/models/instances/#django.db.models.Model django.db.models.Model]. Each attribute of this class corresponds to a database field. This makes it possible to use an automatically generated database access API.
<pre>
from django.db import models
class Person(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
</pre>
The database columns first_name and last_name are specified as class attributes and an id field is automatically added to the table.


== Comparison with other Web Frameworks ==
== Comparison with other Web Frameworks ==


== References ==
== References ==

Revision as of 16:25, 14 September 2014

Django

Background

Architecture

Features

Object- Relational Mapper

Django has its own object relational mapper which eases database access. It facilitates writing of model classes directly in python. Model classes can be defined by sub-classing django.db.models.Model. Each attribute of this class corresponds to a database field. This makes it possible to use an automatically generated database access API.

from django.db import models

class Person(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)

The database columns first_name and last_name are specified as class attributes and an id field is automatically added to the table.

Comparison with other Web Frameworks

References