mirror of
https://github.com/django/django.git
synced 2025-10-10 23:39:11 +00:00
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11764 bcc190cf-cafb-0310-a4f2-bffc1f526a37
21 lines
546 B
Python
21 lines
546 B
Python
from django.conf import settings
|
|
from django.db import models, DEFAULT_DB_ALIAS
|
|
|
|
class Book(models.Model):
|
|
title = models.CharField(max_length=100)
|
|
published = models.DateField()
|
|
authors = models.ManyToManyField('Author')
|
|
|
|
def __unicode__(self):
|
|
return self.title
|
|
|
|
class Meta:
|
|
ordering = ('title',)
|
|
|
|
class Author(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
favourite_book = models.ForeignKey(Book, null=True, related_name='favourite_of')
|
|
|
|
def __unicode__(self):
|
|
return self.name
|