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

  • SEARCH
  • Home
  • 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 6246909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:46:30+00:00 2026-05-24T12:46:30+00:00

i am currently playing with django and i want to model a simple relation:

  • 0

i am currently playing with django and i want to model a simple relation: two members of a dance-club should be paired as a dancing couple in order to participate in a dancing-tournament. I already have a simple model for the members:

class Member(models.Model):
  firstname = models.CharField(max_length=32)
  lastname  = models.CharField(max_length=32)
  member_id = models.IntegerField(unique=True)
  def __unicode__(self):
    return self.firstname + ' ' + self.lastname

I also have a tournament Model:

class Tournament(models.Model):
  name = models.CharField(max_length=32)
  def __unicode__(self):
    return self.firstname + ' ' + self.lastname

Since a participant in a tournament is a couple i need to define a couple-relation (at least that would be my guess). But i really don’t get how i’d do that.

tia for any help and tips

  • 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-05-24T12:46:32+00:00Added an answer on May 24, 2026 at 12:46 pm

    You could maybe try defining a model called something like Couple, and two foreign key relationships to the the Member table, with a relationship to the Tournament they are in:

    class Couple(models.Model):
        partner_a = models.ForeignKey(Member)
        partner_b = models.ForeignKey(Member)
        tournament = models.ForeignKey(Tournament)
    

    I’m not sure of your requirements, but the way I presented allows members to be part of multiple couples, and a couple is unique to a tournament. Depending on how you want do it, you may want to have couples to be fixed (i.e Stacey and Bob always dance together). In that case you would probably want to have a many-to-many relationship from Tournament to couple:

    class Tournament(models.Model):
        couples = models.manyToManyField(Couple)
    

    So a couple can be in many tournaments, and a tournament can have many couples.

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

Sidebar

Related Questions

I'm currently playing with django to get acquainted with it. I want to build
I am currently playing around with a navigational based app. Where I want to
I'm playing with django-cms and I want to create an app-hook to an existing
I'm currently playing with reflection and I have problem with my short code: public
I'm currently playing with C, C++ and ASM. I can see that there's always
I am currently playing around with Google's Voice Recognition API for Android SDK. What
I am currently playing with Qt trying to set up a small particle system.
I am currently playing with DotNetOpenAuth to make an ASP.NET (C#) website use OpenID
I'm currently playing around with tipfy on Google's Appengine and just recently ran into
I am currently playing a video in andriod from the url http://daily3gp.com/vids/747.3gp its working

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.