Cannot use QuerySet for "Product": Use a QuerySet for "Item".

Note, this is incomplete in this situation, because in the case where the slug being submitted is not valid, item will be null. If item is null, then the get_or_create call will fail.

You either want to verify that item is a valid object, or use .get and catch the error if it occurs. Either way, there needs to be guards around this block of code.

2 Likes