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

From Expertiza_Wiki
Jump to navigation Jump to search
Line 27: Line 27:


  2.Enter the username
  2.Enter the username
<pre>
<pre>
Username: admin
Username: admin
</pre>
</pre>
  3. Enter email address
  3. Enter email address
<pre>
<pre>
Email address: admin@example.com
Email address: admin@example.com
</pre>
</pre>
  4. Final step is to setup a password as follows and the admin gets created.
  4. Final step is to setup a password as follows and the admin gets created.
<pre>
<pre>
Password: **********
Password: **********

Revision as of 16:38, 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.

Automatic admin interface

Generating admin sites for the staff to add,change or delete content is made easy by Django by automating the creation of admin interfaces for models. Creating an admin user is as easy as follows:

1. Create a user
$ python manage.py createsuperuser
2.Enter the username
Username: admin
3. Enter email address
Email address: admin@example.com
4. Final step is to setup a password as follows and the admin gets created.
Password: **********
Password (again): *********
Superuser created successfully

Comparison with other Web Frameworks

References