mirror of
https://github.com/django/django.git
synced 2024-11-19 07:54:07 +00:00
20ad30713e
See `docs/topics/db/raw.txt` for details. Thanks to seanoc for getting the ball rolling, and to Russ for wrapping things up. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11921 bcc190cf-cafb-0310-a4f2-bffc1f526a37
25 lines
899 B
Python
25 lines
899 B
Python
from django.db import models
|
|
|
|
class Author(models.Model):
|
|
first_name = models.CharField(max_length=255)
|
|
last_name = models.CharField(max_length=255)
|
|
dob = models.DateField()
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(Author, self).__init__(*args, **kwargs)
|
|
# Protect against annotations being passed to __init__ --
|
|
# this'll make the test suite get angry if annotations aren't
|
|
# treated differently than fields.
|
|
for k in kwargs:
|
|
assert k in [f.attname for f in self._meta.fields], \
|
|
"Author.__init__ got an unexpected paramater: %s" % k
|
|
|
|
class Book(models.Model):
|
|
title = models.CharField(max_length=255)
|
|
author = models.ForeignKey(Author)
|
|
|
|
class Coffee(models.Model):
|
|
brand = models.CharField(max_length=255, db_column="name")
|
|
|
|
class Reviewer(models.Model):
|
|
reviewed = models.ManyToManyField(Book) |