Skip to content
Advertisement

Django – store.models.Customer.MultipleObjectsReturned: get() returned more than one Customer — it returned 2″

I am trying to make an e-commerce website where “AnonymousUser” or Guest user can order and check out products by providing their name, email, and address. But after clicking the “Make Payment” button, my terminal was having an error that says “store.models.Customer.MultipleObjectsReturned: get() returned more than one Customer — it returned 2!”

When I try to login and do the process for an authenticated user, it doesn’t have an error. It just happen to AnonymousUsers.

Here’s my checkout.html:

JavaScript

Here’s my models.py:

JavaScript

Here’s my views.py:

JavaScript

And here’s my utils.py:

JavaScript

How can I get rid of that error and let guest users check out without the need to make an account or login?

EDITED:

When I check all the info I entered in the checkout from in the admin site, I encountered an error that says “str returned non-string (type NoneType)”

Here’s the problem:

JavaScript

Here’s the traceback in my Terminal:

JavaScript

Advertisement

Answer

Here you are creating Customer object for AnonymousUser (simply not logged User).

JavaScript

I think it might find more that one if you have same email used more than once with.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement