PageRenderTime 243ms CodeModel.GetById 151ms app.highlight 3ms RepoModel.GetById 88ms app.codeStats 0ms

/tests/modeltests/lookup/models.py

https://code.google.com/p/mango-py/
Python | 29 lines | 19 code | 5 blank | 5 comment | 0 complexity | 7e7b20eb236571fce9624fe55d0be830 MD5 | raw file
 1"""
 27. The lookup API
 3
 4This demonstrates features of the database API.
 5"""
 6
 7from django.db import models, DEFAULT_DB_ALIAS, connection
 8from django.conf import settings
 9
10class Author(models.Model):
11    name = models.CharField(max_length=100)
12    class Meta:
13        ordering = ('name', )
14
15class Article(models.Model):
16    headline = models.CharField(max_length=100)
17    pub_date = models.DateTimeField()
18    author = models.ForeignKey(Author, blank=True, null=True)
19    class Meta:
20        ordering = ('-pub_date', 'headline')
21
22    def __unicode__(self):
23        return self.headline
24
25class Tag(models.Model):
26    articles = models.ManyToManyField(Article)
27    name = models.CharField(max_length=100)
28    class Meta:
29        ordering = ('name', )