d33tah
d33tah

Reputation: 11561

Why does Django add "IS NULL" here?

Consider the following model:

class ProductCountry(models.Model):
    product = models.OneToOneField('Product')
    country_code = models.CharField(max_length=2)
    count = models.IntegerField()

And an expression print(ProductCountry.objects.filter(product__product_id=request.GET.get('product').query).

Why does it give me the following?

SELECT "precomputed_product_country"."id", "precomputed_product_country"."product_id", "precomputed_product_country"."country_code", "precomputed_product_country"."count" FROM "precomputed_product_country" WHERE "precomputed_product_country"."product_id" IS NULL

Upvotes: 1

Views: 25

Answers (1)

d33tah
d33tah

Reputation: 11561

Apparently I didn't have a product key in GET, as user "soon" pointed out. Fixing the request solved the problem.

Upvotes: 1

Related Questions