-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
25 lines (18 loc) · 787 Bytes
/
Copy pathmodels.py
File metadata and controls
25 lines (18 loc) · 787 Bytes
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
from django.db import models
from django.conf import settings
class Question(models.Model):
title = models.CharField(max_length=140)
description = models.CharField(max_length=320, blank=True)
date_created = models.DateTimeField(auto_now_add=True)
owner = models.ForeignKey(settings.AUTH_USER_MODEL)
#tags = models.ManyToManyField('tags.Tag', blank=True)
class Meta:
ordering = ['-date_created', 'title', ]
def __str__(self):
return self.title
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
text = models.CharField(max_length=200)
date_created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return 'Question {} | {}'.format(self.question.id, self.text)