mirror of
https://github.com/django/django.git
synced 2024-11-28 21:43:13 +01:00
e01cb07404
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15248 bcc190cf-cafb-0310-a4f2-bffc1f526a37
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
from django.db import models
|
|
|
|
from django.contrib.contenttypes import generic
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
class Award(models.Model):
|
|
name = models.CharField(max_length=25)
|
|
object_id = models.PositiveIntegerField()
|
|
content_type = models.ForeignKey(ContentType)
|
|
content_object = generic.GenericForeignKey()
|
|
|
|
class AwardNote(models.Model):
|
|
award = models.ForeignKey(Award)
|
|
note = models.CharField(max_length=100)
|
|
|
|
class Person(models.Model):
|
|
name = models.CharField(max_length=25)
|
|
awards = generic.GenericRelation(Award)
|
|
|
|
class Book(models.Model):
|
|
pagecount = models.IntegerField()
|
|
|
|
class Toy(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
|
|
class Child(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
toys = models.ManyToManyField(Toy, through='PlayedWith')
|
|
|
|
class PlayedWith(models.Model):
|
|
child = models.ForeignKey(Child)
|
|
toy = models.ForeignKey(Toy)
|
|
date = models.DateField(db_column='date_col')
|
|
|
|
class PlayedWithNote(models.Model):
|
|
played = models.ForeignKey(PlayedWith)
|
|
note = models.TextField()
|
|
|
|
class Contact(models.Model):
|
|
label = models.CharField(max_length=100)
|
|
|
|
class Email(Contact):
|
|
email_address = models.EmailField(max_length=100)
|
|
|
|
class Researcher(models.Model):
|
|
contacts = models.ManyToManyField(Contact, related_name="research_contacts")
|