4. About Redis Cache shopping cart and checkout center-other configuration articles

Source: Internet
Author: User

api/urls.py

From Django.conf.urls import URL
From api.views import Shoppingcar, payment, order

Urlpatterns = [
URL (r ' ^shoppingcar/$ ', Shoppingcar. Shoppingcarviewset.as_view ()),
URL (r ' ^payment/$ ', payment. Paymentviewset.as_view ()),
URL (r ' ^order/$ ', order. Orderviewset.as_view ()),
]

mysite/urls.py
From Django.conf.urls import URL, include
From Django.contrib Import admin

Urlpatterns = [
URL (r ' ^admin/', admin.site.urls),
URL (r ' ^api/(? p<version>\w+)/', Include ("Api.urls")),
]

settings.py
Rest_framework = {
' Default_versioning_class ': ' rest_framework.versioning.URLPathVersioning ',
' Allowed_versions ': [' v1 ', ' v2 '], # allowed versions

}
# Redis Settings
CACHES = {
"Default": {
"Backend": "Django_redis.cache.RedisCache",
"Location": "redis://127.0.0.1:6379",
"OPTIONS": {
"Client_class": "Django_redis.client.DefaultClient",
"Connection_pool_kwargs": {"max_connections": 100},
"PASSWORD": "123456",
}
}
}

# Shopping Cart Related Settings
Shopping_car_key = "shopping_car_%s_%s"
Payment_key = "payment_%s_%s"
Payment_coupon_key = "payment_coupon_%s"

utils/response.py
Class Baseresponse (object):

def __init__ (self):
Self.code = 1000
Self.data = None
Self.error = None

@property
def dict (self):
Return self.__dict__

4. About Redis Cache shopping cart and checkout center-other configuration articles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.