I am trying to make a query that is way too complicated for my novice Django skills…
I would like to query a list of products (Product model) that haven’t been listed (Listing model) by a specific facebook account (FacebookAccount).
class Product(models.Model):
sku = models.CharField(max_length=100, unique=True)
title = models.CharField(max_length=255, null=True, blank=True)
mark_as_complete = models.BooleanField(default=False)
class Listing(models.Model):
product = models.ForeignKey(Product, related_name='listings', on_delete=models.CASCADE, null=True, blank=True)
facebook_account = models.ForeignKey(FacebookAccount, related_name='facebook_account', on_delete=models.CASCADE, null=True, blank=True)
listing_price = models.DecimalField(decimal_places=2, max_digits=10, null=True, blank=True)`
location = models.CharField(max_length=255, null=True, blank=True)
My queryset is:
def get_queryset(self):
#listings = Listing.objects.filter(facebook_account__slug=self.kwargs.get('slug'))
queryset = Product.objects.filter(mark_as_complete=True)
return queryset
Thanks in advance for any help! I have about 6 hours into this so far with no luck with anything I’ve tried.