File: models.py

package info (click to toggle)
django-filter 0.5.3-3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 240 kB
  • sloc: python: 1,073; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,292 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
### these models are for testing

from django.db import models


STATUS_CHOICES = (
    (0, 'Regular'),
    (1, 'Admin'),
)

class User(models.Model):
    username = models.CharField(max_length=255)
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)

    status = models.IntegerField(choices=STATUS_CHOICES, default=0)

    is_active = models.BooleanField()

    favorite_books = models.ManyToManyField('Book')

    def __unicode__(self):
        return self.username

class Comment(models.Model):
    text = models.TextField()
    author = models.ForeignKey(User)

    date = models.DateField()
    time = models.TimeField()

    def __unicode__(self):
        return "%s said %s" % (self.author, self.text[:25])


class Article(models.Model):
    published = models.DateTimeField()
    author = models.ForeignKey(User, null=True)


class Book(models.Model):
    title = models.CharField(max_length=100)
    price = models.DecimalField(max_digits=6, decimal_places=2)
    average_rating = models.FloatField()

    def __unicode__(self):
        return self.title

class Place(models.Model):
    name = models.CharField(max_length=100)

    class Meta:
        abstract = True

class Restaurant(Place):
    serves_pizza = models.BooleanField()