Reputation: 367
Here is my error, and I really can't find anything similar to my problem:
from django.db.models import Q
_entry = Entry.objects.get(Q(slug=slug, author=self.author) & ~Q(id=self.id))
TypeError: bad operand type for unary ~: 'Q'
Upvotes: 1
Views: 1373
Reputation: 267
Not only the '&' but also Comma ',' represents AND in django Q objects so you can also try:
from django.db.models import Q
_entry = Entry.objects.get(Q(slug=slug), Q(author=self.author) , ~Q(id=self.id))
Although I couldn't recreate the error that you get. Also please make sure slug,self.author and self.id have proper type of data to go into respective fields.
Here are the docs for complete reference
Upvotes: 0