收集魔法。
codebehind的Python项目详细描述
因为我不想再做同样的事情了。如果您使用的是django rest框架,那么这可能会对您有所帮助。
功能
- 注册和登录
- 不同的身份验证逻辑(基本、令牌、hmac签名)
- 基本助手
- 因为它使用drf,可浏览rest api!
快速启动
将“代码隐藏”添加到已安装的应用程序设置中,如下所示:
INSTALLED_APPS = [ ... 'codebehind', 'rest_framework', ]
运行python manage.py migrate以创建有用的模型。
在您的*设置中。
REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAdminUser', 'rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'codebehind.authentication.CodeBehindAuthentication', 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ), 'PAGE_SIZE': 20 }
在urls.py中::
from rest_framework import routers from django.conf.urls import include, url from codebehind.views import UsersViewSet, GroupViewSet router = routers.DefaultRouter() router.register(r'users', UsersViewSet,'users') router.register(r'groups', GroupViewSet,'groups') urlpatterns += [ # add this url(r'^v1/', include(router.urls)), ]