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 64447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:47:28+00:00 2026-05-10T18:47:28+00:00

I’m trying to design a model for a application allowing 2 people to bet

  • 0

I’m trying to design a model for a application allowing 2 people to bet with each other (I know, sounds stupid…). What I’m wondering about is how to connect the bet with users. The structure is like this

|-------------|       |----------| |    Bet      |       | User     | | BetUser1    |       |----------| | BetUser2    | | Winner      | | ...         | |-------------| 

So we got 2 people that bet with each other (both are Users from django auth system) and then, after one of them wins, there’s a winner. Now all those 3 fields are of type User, but:

  • Should I make BetUser1 and BetUser2 separate fields, or design some many-to-two relationship here? (with many-to-two being a many-to-many and with some external way of ensuring no more then 2 Users can be assigned to each bet?
  • winner can only be either user 1 or user 2, noone else of course. How should I create this field, yet another ForeignKey(User), or some else?

Just looking for some fresh point of view, as it seems that in such stupid case I’m stuck with the django model system.

  • 1 1 Answer
  • 3 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. 2026-05-10T18:47:29+00:00Added an answer on May 10, 2026 at 6:47 pm

    I would probably add a third model to represent a specific wager someone has placed, as it is conceivable that more than two people could enter into a bet. It would look something like this:

    USER        WAGER              BET              User (FK(User))    Description              Bet  (FK(Bet))     Winner (FK (Wager), null=True)              Amount 

    Django will automatically generate user.wager_set and bet.wager_set based on the foreign keys. This allows you to easily iterate and display the wagers for a bet, as well as the wagers from each user. You can also add a unique_together constraint on User and Bet in the Wager table so that each user can only make one wager.

    When the betting is all done, and a winner has been selected, you just set bet.winner.

    In case you run into it, you might see a warning about related_name by having Bet point to Wager and Wager point to Bet. To fix, just add related_name=wagers to Wager.bet.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I know there's a lot of other questions out there that deal with this
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I don't have much knowledge about the IPv6 protocol, so sorry if the question

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.