2009-11-03 14:02:49 +00:00
|
|
|
from django.db import models
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2009-11-03 14:02:49 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2009-11-03 14:02:49 +00:00
|
|
|
class Author(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2009-11-03 14:02:49 +00:00
|
|
|
return self.name
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2009-11-03 14:02:49 +00:00
|
|
|
class Book(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
authors = models.ManyToManyField(Author)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2009-11-03 14:02:49 +00:00
|
|
|
return self.name
|