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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:15:17+00:00 2026-05-19T12:15:17+00:00

On a model blog I have a ManyToMany field called permissionGroups , which as

  • 0

On a model blog I have a ManyToMany field called permissionGroups, which as the name suggests is a list of groups allowed to access something.

class blog(models.Model):    
    permissionGroups = models.ManyToManyField(groups, null=True, blank=True)
    ...

On another model groups I have a ManyToMany field called allowedUsers which again as the name suggests, is a list of users within that group.

class groups(models.Model):
    allowedUsers = models.ManyToManyField(User, null=True, blank=True)
    ...

So I want to be able to get all groups that the currentUser is in and match any one of those to any one of the permissionGroups of a specific blog.

I hope all that was clear,

Thanks in advance

  • 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-19T12:15:18+00:00Added an answer on May 19, 2026 at 12:15 pm

    What’s the final data you are looking for? A list of groups? A boolean “Can edit / can not edit”?

    To check if a user belongs to a group that belongs to a blog, you can do this:
    user.groups_set.filter(blog=blog) This is the equivalent of checking if a user can edit said blog.

    If you want a list of blogs that a user can edit, you can do this:
    blog.objects.filter(permissiongroups__in=user.groups_set.all())

    Somehow thinking of your models was a mind bender.

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

Sidebar

Related Questions

I have a django model called Blog . I'd like to add a field
I have created a blog app which its model has an author field like
i have an app called blog and blog and Post and Categories model. url(r'^(?P<slug>[-\w]+)/$',
I have a core data model with blog groups, blogs, and posts. A blog
I have models like this class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def
I have a model - Category which HABTM Blog. I need to create a
I have an app with a similar structure as this snippet class Blog(models.Model): name
I have a model for a blog post where the owner of the post
I have a parent model that has many child models, for example: App.Blog =
class Blog(models.Model): name = models.CharField(max_length=100) class Entry(models.Model): blog = models.ForeignKey(Blog) headline = models.CharField(max_length=255) Is

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.