Python django.conf.settings 模块,REST_FRAMEWORK 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.conf.settings.REST_FRAMEWORK

项目:valhalla    作者:LCOGT    | 项目源码 | 文件源码
def api_quota(self):
        '''Get's the amount of requests this user has made in the last 24
        hours as well as the maximum allowed by DRF's throttling framework'''
        hits = cache.get('throttle_user_{0}'.format(self.user.id))
        used = len(hits) if hits else 0
        allowed = settings.REST_FRAMEWORK['DEFAULT_THROTTLE_RATES']['user']
        return {'used': used, 'allowed': allowed}
项目:drf-schema-adapter    作者:drf-forms    | 项目源码 | 文件源码
def get_metadata_from_viewset(self, viewset):

        if isinstance(viewset, dict):
            output = viewset
        else:
            MetadataClass = import_string(django_settings.REST_FRAMEWORK['DEFAULT_METADATA_CLASS'])
            output = MetadataClass().determine_metadata(None, viewset)

        return output
项目:drf-schema-adapter    作者:drf-forms    | 项目源码 | 文件源码
def rebuild_index(self):
        MetadataClass = import_string(django_settings.REST_FRAMEWORK['DEFAULT_METADATA_CLASS'])
        context = {}
        directory = os.path.join(django_settings.BASE_DIR, settings.FRONT_APPLICATION_PATH,
                                 'app', 'data')
        context['items'] = self.walk_dir(directory, True)
        context['root_metadata'] = self.render(
            MetadataClass().determine_metadata(None, 'APIRootView')
        )
        self.write_file(context, directory, 'index.js', self.index_template_name, True)
项目:EvalAI    作者:Cloud-CV    | 项目源码 | 文件源码
def paginated_queryset(queryset, request, pagination_class=PageNumberPagination()):
    '''
        Return a paginated result for a queryset
    '''
    paginator = pagination_class
    paginator.page_size = settings.REST_FRAMEWORK['PAGE_SIZE']
    result_page = paginator.paginate_queryset(queryset, request)
    return (paginator, result_page)