-
Notifications
You must be signed in to change notification settings - Fork 151
/
models.py
40 lines (28 loc) · 971 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
class MyUser(models.Model):
user = models.OneToOneField(User)
nickname = models.CharField(max_length=16)
permission = models.IntegerField(default=1)
def __unicode__(self):
return self.user.username
class Book(models.Model):
name = models.CharField(max_length=128)
price = models.FloatField()
author = models.CharField(max_length=128)
publish_date = models.DateField()
category = models.CharField(max_length=128)
class META:
ordering = ['name']
def __unicode__(self):
return self.name
class Img(models.Model):
name = models.CharField(max_length=128)
description = models.TextField()
img = models.ImageField(upload_to='image/%Y/%m/%d/')
book = models.ForeignKey(Book)
class META:
ordering = ['name']
def __unicode__(self):
return self.name