File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
from django .db import models
2
2
3
- # Create your models here.
3
+
4
+ class Book (models .Model ):
5
+ title = models .CharField (max_length = 100 )
6
+ authors = models .ManyToManyField ('Author' )
7
+ publisher = models .ForeignKey (Publisher )
8
+ publication_date = models .DateField ()
9
+
10
+ def __unicode__ (self ): # __str__ on Python 3
11
+ return self .title
12
+
13
+
14
+ class Author (models .Model ):
15
+ salutation = models .CharField (max_length = 100 )
16
+ name = models .CharField (max_length = 50 )
17
+ email = models .EmailField ()
18
+
19
+ def __unicode__ (self ):
20
+ return self .name
21
+
22
+
23
+ class Publisher (models .Model ):
24
+ name = models .CharField (max_length = 50 )
25
+ address = models .CharField (max_length = 100 )
26
+ website = models .URLField ()
27
+
28
+ def __unicode__ (self ):
29
+ return self .name
You can’t perform that action at this time.
0 commit comments