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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:01:48+00:00 2026-05-10T17:01:48+00:00

Using Django’s built in models, how would one create a triple-join between three models.

  • 0

Using Django’s built in models, how would one create a triple-join between three models.

For example:

  • Users, Roles, and Events are the models.
  • Users have many Roles, and Roles many Users. (ManyToMany)
  • Events have many Users, and Users many Events. (ManyToMany)
  • But for any given Event, any User may have only one Role.

How can this be represented in the model?

  • 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. 2026-05-10T17:01:49+00:00Added an answer on May 10, 2026 at 5:01 pm

    zacherates writes:

    I’d model Role as an association class between Users and Roles (…)

    I’d also reccomed this solution, but you can also make use of some syntactical sugar provided by Django: ManyToMany relation with extra fields.

    Example:

    class User(models.Model):     name = models.CharField(max_length=128)  class Event(models.Model):     name = models.CharField(max_length=128)     members = models.ManyToManyField(User, through='Role')      def __unicode__(self):         return self.name  class Role(models.Model):     person = models.ForeignKey(User)     group = models.ForeignKey(Event)     date_joined = models.DateField()     invite_reason = models.CharField(max_length=64) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 211k
  • Answers 211k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure it is productive to worry about optimizations… May 12, 2026 at 10:09 pm
  • Editorial Team
    Editorial Team added an answer I finally got it to work... A running minimal example… May 12, 2026 at 10:09 pm
  • Editorial Team
    Editorial Team added an answer The objective of the Tasks namespace is to provide a… May 12, 2026 at 10:09 pm

Related Questions

Using Django's built in models, how would one create a triple-join between three models.
Using Django, how do I generate the value of a field the first time
When using django.contrib.comments is there anyway to add the reverse relationship to a model
While using django.core.paginator import ObjectPaginator, I'm getting this error: NeedIndexError: The built-in indices are
im using django-registration, all is fine, the confirmation email was sending in plain text,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.