-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
30 lines (21 loc) · 896 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
from django.db import models
from django.contrib.auth.models import User
from accounts.models import Profile
# Create your models here.
class Question(models.Model):
ques_round = models.IntegerField(default=1,primary_key=True)
types = [
('N','NORMAL'),
('I','IMAGE')
]
question_type = models.CharField(max_length=1,choices=types)
text = models.CharField(max_length=500)
image = models.ImageField(upload_to = 'images/',blank=True)
def __str__(self):
return str(self.ques_round)
class Response(models.Model):
question = models.ForeignKey(Question,on_delete=models.CASCADE)
profile = models.ForeignKey(Profile,on_delete=models.CASCADE)
response = models.CharField(max_length=500)
def __str__(self):
return "{} : {}".format(self.question.ques_round,self.profile.user.first_name+' '+self.profile.user.last_name)