-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodels.py
35 lines (26 loc) · 1.06 KB
/
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
from django.db import models
from tinymce import models as tinymce_models
from django.utils.translation import ugettext_lazy as _
photos_path = "simple-faq/"
class Topic(models.Model):
text = models.CharField(max_length=200)
number = models.IntegerField()
class Meta:
verbose_name = _("Topic")
verbose_name_plural = _("Topics")
ordering = ['number']
def __unicode__(self):
return u'(%s) %s' % (self.number, self.text, )
class Question(models.Model):
text = models.CharField(max_length=200)
answer_text = tinymce_models.HTMLField()
topic = models.ForeignKey(Topic, related_name="questions")
header_picture = models.ImageField(upload_to=photos_path, blank=True)
number = models.IntegerField()
related_questions = models.ManyToManyField("self", related_name="related_questions", blank=True, null=True)
class Meta:
verbose_name = _("Question")
verbose_name_plural = _("Questions")
ordering = ['number']
def __unicode__(self):
return u'(%s) %s' % (self.number, self.text, )