mirror of
https://github.com/django/django.git
synced 2024-11-19 07:54:07 +00:00
24f4764a48
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
29 lines
683 B
Python
29 lines
683 B
Python
"""
|
|
7. The lookup API
|
|
|
|
This demonstrates features of the database API.
|
|
"""
|
|
|
|
from django.db import models
|
|
|
|
class Author(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
class Meta:
|
|
ordering = ('name', )
|
|
|
|
class Article(models.Model):
|
|
headline = models.CharField(max_length=100)
|
|
pub_date = models.DateTimeField()
|
|
author = models.ForeignKey(Author, blank=True, null=True)
|
|
class Meta:
|
|
ordering = ('-pub_date', 'headline')
|
|
|
|
def __unicode__(self):
|
|
return self.headline
|
|
|
|
class Tag(models.Model):
|
|
articles = models.ManyToManyField(Article)
|
|
name = models.CharField(max_length=100)
|
|
class Meta:
|
|
ordering = ('name', )
|