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