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