If you want to show the items relative to the currently logged in user, try
adding this option => limit_choices_to={'user' : 'user'}, to your items
field in models.py



On Tuesday, 1 June 2021, Aritra Ray <[email protected]> wrote:

> Right, thank you so much.
>
> Regards.
>
> On Tue, 1 Jun, 2021, 8:27 pm oba stephen, <[email protected]> wrote:
>
>> You should return this if you want to redirect to cart;
>>
>> return redirect(reverse("store:cart-page", kwargs={"id": <the ID of the
>> cart>}))
>>
>> Best regards
>>
>> Stephen Oba
>>
>> On Tue, Jun 1, 2021, 3:27 PM Aritra Ray <[email protected]> wrote:
>>
>>> Sure, here's the file.
>>>
>>> [image: 2021-06-01 (6).png]
>>>
>>> Regards,
>>> Aritra.
>>>
>>> On Tue, 1 Jun 2021 at 19:45, oba stephen <[email protected]> wrote:
>>>
>>>> Can I see your urls.py?
>>>>
>>>> Best regards
>>>>
>>>> Stephen Oba
>>>>
>>>> On Tue, Jun 1, 2021, 3:05 PM Aritra Ray <[email protected]> wrote:
>>>>
>>>>> Oh, okay. I was unaware of that. Although, my cart page is getting
>>>>> redirected back to home page. Can you spot any mistake in the provided
>>>>> screenshots?
>>>>> Also, can you please guide on how to redirect a function to the
>>>>> previously visited page? Like add-to-cart should redirect to either
>>>>> products page or cart page itself depending on which page the user called
>>>>> it from.
>>>>>
>>>>> On Tue, 1 Jun, 2021, 6:37 pm oba stephen, <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I don't think you have an error here. Although I haven't looked at
>>>>>> the code, but from your django admin page I can see that none of those
>>>>>> items are selected.
>>>>>>
>>>>>> If you run a query from your terminal, you would notice that the
>>>>>> items would return as empty.
>>>>>>
>>>>>> When you create a many to many relationship in django, all objects on
>>>>>> that related model would display this way.
>>>>>>
>>>>>> What is the difference between different carts?  The difference is,
>>>>>> the items would be selected or highlighted in a cart they belong to.
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> Best regards
>>>>>>
>>>>>> Stephen Oba
>>>>>>
>>>>>> On Tue, Jun 1, 2021, 1:52 PM Aritra Ray <[email protected]> wrote:
>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>> This is Aritra reposting the same error. I have a problem regarding
>>>>>>> an E-commerce Django website where the cart model on the admin page is
>>>>>>> showing the items added to cart by one user to all other users as well.
>>>>>>> I have a Profile model and a Cart model attached below. The views.py
>>>>>>> has been attached too. Kindly comment back if anything else is needed.
>>>>>>> Thanks in advance.
>>>>>>>
>>>>>>>
>>>>>>> Regards,
>>>>>>> Aritra
>>>>>>>
>>>>>>> Error:
>>>>>>>
>>>>>>> [image: 2021-06-01 (4).png]
>>>>>>>
>>>>>>> Views.py
>>>>>>>
>>>>>>> [image: 2021-06-01 (1).png][image: 2021-06-01 (5).png]
>>>>>>>
>>>>>>> Models.py
>>>>>>>
>>>>>>> [image: 2021-06-01 (2).png][image: 2021-06-01 (3).png]
>>>>>>>
>>>>>>> --
>>>>>>> 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/CAFecadtNZeLb
>>>>>>> atpdnuC_RUDdjLjbrvZTO%2BMVD7hPuHNkN%2Bv%2BBA%40mail.gmail.com
>>>>>>> <https://groups.google.com/d/msgid/django-users/CAFecadtNZeLbatpdnuC_RUDdjLjbrvZTO%2BMVD7hPuHNkN%2Bv%2BBA%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/CAAJsLnpYBVfa
>>>>>> cxd3NJ7sqnC6dD2b6nBQw%3DFqfQe9Od1%2BpwTHww%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/django-users/CAAJsLnpYBVfacxd3NJ7sqnC6dD2b6nBQw%3DFqfQe9Od1%2BpwTHww%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/CAFecadvZ11v-
>>>>> bvZzCXUVUTpr0WBa6eVmF7M6qpoVRFNF5dS%2Bcg%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAFecadvZ11v-bvZzCXUVUTpr0WBa6eVmF7M6qpoVRFNF5dS%2Bcg%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/ms
>>>> gid/django-users/CAAJsLnqwLQNwKExW23UW%3DgiF_co-
>>>> rZ1adHcSmx6ZUSg4rDp61w%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAAJsLnqwLQNwKExW23UW%3DgiF_co-rZ1adHcSmx6ZUSg4rDp61w%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/ms
>>> gid/django-users/CAFecaduG3p6QS%2BxdGv%2B6zi4jH_x%2BQPm%
>>> 3D0TjoKjb2K8-pHc6%3DEw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAFecaduG3p6QS%2BxdGv%2B6zi4jH_x%2BQPm%3D0TjoKjb2K8-pHc6%3DEw%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/ms
>> gid/django-users/CAAJsLnoFZZegG9bmvMLCmxhp%2B%3D6%
>> 3DnoaajxJ1m%2Ba8LXAP%2Bhk%2B9Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAJsLnoFZZegG9bmvMLCmxhp%2B%3D6%3DnoaajxJ1m%2Ba8LXAP%2Bhk%2B9Q%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/ms
> gid/django-users/CAFecadtUShE1Hn_jVasfJ3sU24ctaT4YqVBHRw4T_f
> Wn1nW08Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAFecadtUShE1Hn_jVasfJ3sU24ctaT4YqVBHRw4T_fWn1nW08Q%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/CAJ4Kmg5k7HuKdEx0jO%3D3PN%3DWd36eBLeAXmJ64Y9hTBa4q%2Bj%3D7w%40mail.gmail.com.

Reply via email to