Got an error while checkout without signing in

Submitted 3 years, 8 months ago
Ticket #97
Views 237
Language/Framework Django
Priority Medium
Status Closed

Hello,

I was just try to build django ecommerce site from just django channel .Then i got an error User matching query does not exist. These are the steps :

1. I install all requirements.txt.

2.then added secret key, and set up own sandbox in the pay pal client.

3.Then (all these step are done without login / without register an account) I went to shop > added product to cart > procced to checkout.

I got this error:

. Here it the link of github repo (go to branch 20- stock, there i got error):

https://github.com/justdjango/django-simple-ecommerce/tree/20-stock

I guess without login if someone tries to checkout then it should redirect to login page/signup page. correct me if i am wrong.Can anyone help me with this error ?

Submitted on Aug 07, 20
add a comment

1 Answer

@ Swastikshrestha0001 . I am unable to get your question here. Do you want us to test the github code which you sent?. Sorry we will not do that until you do the preliminary steps from your end.

However from the snapshot you shared ,its clearing saying the User doesnt exists in the database.

  1. Create the superuser first
  2. Login Admin with superuser which you created in first step
  3. Try navigate to checkout page in same browser which you logged in as admin
  4. Now you will not get this error.

Or in your view you can use the below code in order to avoid the above steps,

from django.shortcuts import get_object_or_404

user = get_object_or_404(User, pk=user_id)

Submitted 3 years, 8 months ago

@sunil I have tried to redirect in login page while anyone tries to checkout without making an account but it didn`t work. Like you said i know there must be a user account but here i want new user to select the product and add to cart then checkout but while checkout without an account that new user should be redirect to signup/signin page. After that they can checkout which they have add to cart. As i mention above that github repo link i have done till branch 20-stock and i am stuck with that error , just want some help to solve that issue.

- swastikshrestha0001 3 years, 8 months ago

@loginrequired decorator in your view. Then it should redirect to home page what you are given in settings.py.

- sunil 3 years, 8 months ago

If the issue has been resolved. Could you close the ticket ?

- Vengat 3 years, 8 months ago


Latest Blogs