1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

[soc2009/multidb] Add multi-db support to fixture loading. Involves a rework of models in the multi-db test cases to make the fixture a complete test case. Patch from Russell Keith-Magee.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11891 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor
2009-12-17 16:12:43 +00:00
parent 3c8c3bd651
commit 44f21f2374
14 changed files with 195 additions and 126 deletions

View File

@@ -16,10 +16,25 @@ class Review(models.Model):
class Meta:
ordering = ('source',)
class PersonManager(models.Manager):
def get_by_natural_key(self, name, using=DEFAULT_DB_ALIAS):
return self.using(using).get(name=name)
class Person(models.Model):
objects = PersonManager()
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class Meta:
ordering = ('name',)
class Book(models.Model):
title = models.CharField(max_length=100)
published = models.DateField()
authors = models.ManyToManyField('Author')
authors = models.ManyToManyField(Person)
editor = models.ForeignKey(Person, null=True, related_name='edited')
reviews = generic.GenericRelation(Review)
def __unicode__(self):
@@ -28,16 +43,6 @@ class Book(models.Model):
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
class Meta:
ordering = ('name',)
class UserProfile(models.Model):
user = models.OneToOneField(User)
flavor = models.CharField(max_length=100)