Let's say I want to ask a User
a Question
: "Order the following animals from biggest to smallest". Here's a little simplified django:
class Question(models.Model):
text = models.CharField() #eg "Order the following animals..."
class Image(models.Model):
image = models.ImageField() #pictures of animals
fk_question = models.ForeignKey(Question)
Now I can assign a variable number of Image
s to each Question
, and customize the question text. Yay.
What would be the appropriate way to record the responses? Obviously I'll need foreign keys to the User
and the Question
:
class Response(models.Model):
fk_user = models.ForeignKey(User)
fk_question = models.ForeignKey(Question)
But now I'm stuck. How do I elegantly record the order of the Image
objects that this User
specified?
Edit: I'm using Postgres 9.5