Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7750687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:21:19+00:00 2026-06-01T11:21:19+00:00

having this two classes I always have a doubt of which is the best

  • 0

having this two classes I always have a doubt of which is the best practice “linking” them ( if any)

Question

class Question(models.Model):
    text = models.CharField('Question',max_length=120)
    created = models.DateTimeField(auto_now_add=True)
    opens = models.DateTimeField()
    closes = models.DateTimeField()

Answer

class Answer(models.Model):
    text =  models.CharField('Answer',max_length=120)
    votes = models.IntegerField(default=0)

Wrong – I can add this line to Answer (this was a copy / paste error):

answers = models.ForeignKey(Answer)

Edit:

answers = models.ManyToManyField(Answer)

I can add this line to Answer:

question = models.ForeignKey(Question)

I would like to know if it really doesn’t matter or I should consider different aspects.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:21:20+00:00Added an answer on June 1, 2026 at 11:21 am
    class Question: 
        answer = models.ForeignKey(Answer)
    

    “This particular question has only one possible answer”.


    class Answer: 
        question = models.ForeignKey(Question)
    

    “This answer belongs to one particular question only, but that question might have multiple separate answers”


    class Answer:
        question = models.ManyToManyField(Question)
    

    “This particular answer is an answer to multiple questions. So questions can have multiple separate answers”


    class Question:
        answers = modes.ManyToManyField(Answer)
    

    “This question has multiple distinct answers. Also answers can belong to multiple questions.” [Best approach]


    An question has to have answers. You don’t make an answer (usually) to answer multiple questions, instead, an answer answers one particular question, but there may be multiple answers (from different users for example). Therefore I’d pick 4 .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm having this problem. I have two tables (Oracle), one is called Destination
i have two sheets having data like this sheet1 : **A** **B** **C** 752
Having difficulty articulating this correlated subquery. I have two tables fictitious tables, foo and
I am having a really hard time getting this to work. I have two
I have two classes SccmAction and TicketAction which both implement interface IDelivery. These classes
I have two classes: a base class, Foo::Base and a derived class, Foo::Base::Sub .
I have defined two classes below: public class junk { private BigInteger a =
good morning, I was trying the SharedPreferences Class and I have created two classes,
I'm new to rails and having issues with scope. I have two classes, Post
How can I create two classes that have member pointers to each other's class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.