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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:43:16+00:00 2026-06-13T08:43:16+00:00

I am using Django framework, appengine database. My code for model is: class Group(models.Model):

  • 0

I am using Django framework, appengine database.

My code for model is:

class Group(models.Model):
    name = models.CharField(max_length=200)
    ispublic = models.BooleanField()
    logo = models.CharField(max_length=200)
    description = models.CharField(max_length=200)
    groupwebsite = models.CharField(max_length=200)
    owner = models.ForeignKey('profile')


class Group_members(models.Model):
    profile = models.CharField(max_length=200)
    group = models.ForeignKey('group')

I am querying on Group_members to remove group. My query is as follows:

groups = Group_members.objects.filter(Q(profile=profile.id),~Q(group__in=group_id)

INFO:

  1. group_id = ['128','52']
  2. group is a foreign key to group model

My problem is when I run this query, it throws Database error: Lookup type 'in' can't be negated.

I have also performed query using __in it worked fine but does not work for foreign key.

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-06-13T08:43:17+00:00Added an answer on June 13, 2026 at 8:43 am

    I think you trying to filter profile id and remove groups in group_id in single filter

    groups = Group_members.objects.filter(Q(profile=profile.id),~Q(group__in=group_id)
    

    instead try this:

    1)first filter the profiles form group_member :

    groups = Group_members.objects.filter(profile=profile.id)
    

    2)remove the groups form Queryset by:

    groupId = [x.group.id for x in groups if x.group.id not in group_id]
    

    Hope this will give you perfect result

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

Sidebar

Related Questions

This is using the web app framework, not Django. The following template code is
I have an apache httpd server running python code using django framework and mod_wsgi.
I write code with Python using Django framework. Now I have read about all
Using django comments framework http://docs.djangoproject.com/en/dev/ref/contrib/comments/ Not sure is there option, to make all comments
I'm developing a website using the Django framework, and I need to retrieve Jabber
I want to create a new business application using the Django framework. Any suggestions
I have a django site using the basic django registration framework. I have my
using django 1.4 I have a model with a datetimefield. I imported django.utils.timezone to
I am using the django framework and am using templates, inheriting a lot of
I am struggling to run unit tests using the Django Client class on the

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.