[Answered ]-How to get the foreignkey attribute value

1👍

There can be multiple OrderItems for such customer. You filter with:

def test():
    email = 'foo@bar.com'
    customer_email = OrderItem.objects.filter(order__customer__email=email)
    print(customer_email)

If you have an OrderItem object you use:

myorderitem.order.customer.email

Leave a comment