You are welcome 😀

On Sun, Sep 20, 2020 at 9:08 PM King Niko <[email protected]>
wrote:

> This method works! Thank you!
>
> On Sat, Sep 19, 2020 at 23:32 RANGA BHARATH JINKA <
> [email protected]> wrote:
>
>> Hi,
>>
>>     Try this.
>>
>> https://stackoverflow.com/questions/36317816/relatedobjectdoesnotexist-user-has-no-userprofile
>>
>>
>>  All the best 👍
>>
>> On Sun, 20 Sep 2020, 8:50 am Lightning Bit, <
>> [email protected]> wrote:
>>
>>> Encountering a lot of errors here. Here is the spill:
>>>
>>>
>>> *THE CASE:*
>>> So, I have created the base site with an operational store. However, now
>>> I am trying to add new users.
>>>
>>> I completed about half of the "setting up user accounts" tutorial,
>>> however, now, whenever a new user logs in, he/she is unable to access any
>>> of the pages on the website.
>>>
>>> *THE CAUSE*
>>> In fact, an "Exception Type: RelatedObjectDoesNotExist" and "Exception
>>> Value: User has no customer" appears.. This is stopping the website from
>>> being operational for new users.
>>>
>>> In the traceback, I am shown the following from "views.py" - "data =
>>> cartData(request)". Then, I am shown the following form "utils.py" -
>>> "customer = request.user.customer". This seems to be what is causing the
>>> errors.
>>>
>>> *Views.py *
>>>
>>> def about(request):
>>>
>>>     data= cartData(request)
>>>
>>>     items=data['items']
>>>     order=data['order']
>>>     cartItems=data['cartItems']
>>>
>>>     context = {'items':items, 'order':order, 'cartItems':cartItems}
>>>     return render(request, 'store/about.html', context)
>>>
>>>
>>>
>>> *CartData from Utils.py*
>>>
>>>
>>> def cartData(request):
>>>             if request.user.is_authenticated:
>>>                         customer = request.user.customer
>>>
>>>                         order, created = 
>>> Order.objects.get_or_create(customer=customer, complete=False)
>>>                         items = order.orderitem_set.all()
>>>                         cartItems=order.get_cart_items
>>>             else:
>>>                         cookieData = cookieCart(request)
>>>                         cartItems = cookieData['cartItems']
>>>                         order = cookieData['order']
>>>                         items = cookieData['items']
>>>
>>>             return{'cartItems':cartItems, 'order':order, 'items':items}
>>>
>>>
>>> *THE CONFUSION*
>>> However, the store will not operate if I get rid of the
>>> cartData(request). How can I reconfigure the "views.py" or "utils.py" to
>>> make the cartData(request) operational for both admin and customers w/o
>>> this error appearing?
>>>
>>> Thanks everyone, I hope that someone knows how to bypass this.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>>
>>>
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>>
>>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/6f1e5336-8ffe-4955-989e-ec166649de82n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/6f1e5336-8ffe-4955-989e-ec166649de82n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>>
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>>
>>
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>>
>>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAK5m316h3JpBpjWF1uWsentu47VnzDuYi0P2OXo_o2zwV8Qf2w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAK5m316h3JpBpjWF1uWsentu47VnzDuYi0P2OXo_o2zwV8Qf2w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAO1EWpGvcgVwkPSFzQ6Tk826yu7BfDyn_CgogFzPnMwKBHu%3DSA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAO1EWpGvcgVwkPSFzQ6Tk826yu7BfDyn_CgogFzPnMwKBHu%3DSA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks and Regards

J. Ranga Bharath
cell: 9110334114

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK5m315XU1fFjZEn5yMQtFOom%2BC0qb2j4JQT1HR45yxWioMU_g%40mail.gmail.com.

Reply via email to