[Fixed]-Remove model name in loop | Django ORM

1👍

for i in Rental.objects.filter(inventory__film_id=2).order_by("inventory_id"):
    amnt=Payment.objects.filter(rental_id= int(i.rental_id))
    print ("Rental of %s is %s") %(i, amnt[0].amount)

Since an object of payment is returned to you, you have to mention which field you are going to display.

Leave a comment