A
A
Azamat2016-09-07 00:02:49
Django
Azamat, 2016-09-07 00:02:49

What is the best way to organize a shopping cart in an online store using Django?

I started using django not so long ago and the following question arose:
when you click on a certain product of the online store, you need to add it to the cart with information about the quantity of the purchased product. The entire cart is displayed when clicked in the pop-up window. What django tools to use for this? What is the best way to implement all this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
planc, 2016-09-07
@planc

there are examples in this book:
djangobyexample.com

A
Alexey Cheremisin, 2016-09-07
@leahch

I have implemented a shopping cart in redis. I use hash for this. The hash key is the cart id.
You can add a product with one request! You can put TTL on the trash and it will be deleted automatically, the main database is not involved! Solid cool!

127.0.0.1:6379> HINCRBY cart:12345 item:4321 1
(integer) 1
127.0.0.1:6379> HINCRBY cart:12345 item:4321 1
(integer) 2
127.0.0.1:6379> HINCRBY cart:12345 item:4345 1
(integer) 1
127.0.0.1:6379> HINCRBY cart:12345 item:4345 1
(integer) 2
127.0.0.1:6379> HINCRBY cart:12345 item:3456 1
(integer) 1
127.0.0.1:6379> HINCRBY cart:12345 item:4321 1
(integer) 3
127.0.0.1:6379> HGETALL cart:12345
1) "item:4321"
2) "3"
3) "item:4345"
4) "2"
5) "item:3456"
6) "1"
127.0.0.1:6379> HINCRBY cart:12345 item:4321 4
(integer) 7
127.0.0.1:6379> HGETALL cart:12345
1) "item:4321"
2) "7"
3) "item:4345"
4) "2"
5) "item:3456"
6) "1"
127.0.0.1:6379>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question