Home > Back-end >  Demo a question ask by a normal persion oke
Demo a question ask by a normal persion oke

Time:01-09

A user can ask many questions.

How many = User.question_set.all().count() A question can be bookmarked by many users (once per user).

How many = Question.bookmark_set.all().count() How many users have bookmarked the all questions asked by a single user?

How many = ??? My models:

class Question(models.Model):
    question = models.CharField()

class Answer(models.Model):
    answer = models.CharField()

class Bookmark(models.Model):
    user = models.ForeignKey(User)
    question = models.ForeignKey(Question)

CodePudding user response:

I think if you use some framework like Laravel its defined some relationship like hasMany

CodePudding user response:

I just test the way to answer one question.

  •  Tags:  
  • Related