1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00
Signed-off-by: Jason Myers <jason@jasonamyers.com>
This commit is contained in:
Jason Myers
2013-11-02 17:50:35 -05:00
parent 8eec2d93b6
commit 3f115776e1
16 changed files with 172 additions and 5 deletions

View File

@@ -18,10 +18,12 @@ class Review(models.Model):
class Meta:
ordering = ('source',)
class PersonManager(models.Manager):
def get_by_natural_key(self, name):
return self.get(name=name)
@python_2_unicode_compatible
class Person(models.Model):
objects = PersonManager()
@@ -33,6 +35,7 @@ class Person(models.Model):
class Meta:
ordering = ('name',)
# This book manager doesn't do anything interesting; it just
# exists to strip out the 'extra_arg' argument to certain
# calls. This argument is used to establish that the BookManager
@@ -46,6 +49,7 @@ class BookManager(models.Manager):
kwargs.pop('extra_arg', None)
return super(BookManager, self).get_or_create(*args, **kwargs)
@python_2_unicode_compatible
class Book(models.Model):
objects = BookManager()
@@ -62,6 +66,7 @@ class Book(models.Model):
class Meta:
ordering = ('title',)
@python_2_unicode_compatible
class Pet(models.Model):
name = models.CharField(max_length=100)
@@ -73,6 +78,7 @@ class Pet(models.Model):
class Meta:
ordering = ('name',)
class UserProfile(models.Model):
user = models.OneToOneField(User, null=True)
flavor = models.CharField(max_length=100)