Before we start looking at views and URLs, let's create a sample application to experiment with. Since most books and examples use blog models as their demos, let's keep things fresh by making our demo a press release application for a company website. The press release object will have a title, body, published date, and author name.
In the root directory of your project (in the directory projects/mycompany
), create the press application by using the startapp
command:
$ python manage.py startapp press
This will create a press
folder in your site. Edit the mycompany/press/models.py
file:
from django.db import models class PressRelease(models.Model): title = models.CharField(max_length=100) body = models.TextField() pub_date = models.DateTimeField() author = models.CharField(max_length=100) def __unicode__(self): return self.title