Saravanan666/pypi-org huggingface dataset:
Package: djangorestframework-reactive
This package enables regular Django REST Framework views to become reactive,
that is so that client-side applications may get notified of changes to the
underlying data as soon as they happen, without the need to poll the API
again. While the initial request is done as a regular HTTP request, all the
update notifications come through WebSockets.InstallPrerequisitesThe reactive extensions for Django REST Framework require the use ofDjango Channelsfor push notifications via WebSockets.From PyPIpip install djangorestframework-reactiveFrom sourcepip install https://github.com/genialis/django-rest-framework-reactive/archive/<git-tree-ish>.tar.gzwhere<git-tree-ish>can represent any commit SHA, branch name, tag name,
etc. inDRF Reactive’s GitHub repository. For example, to install the latest
version from themasterbranch, use:pip install https://github.com/genialis/django-rest-framework-reactive/archive/master.tar.gzConfigureFirst, addrest_framework_reactivetoINSTALLED_APPS.Configure your Django Channelsrouting.pyto include the required paths:from django.urls import path

from channels.routing import ChannelNameRouter, ProtocolTypeRouter, URLRouter

from rest_framework_reactive.consumers import ClientConsumer, MainConsumer, WorkerConsumer
from rest_framework_reactive.protocol import CHANNEL_MAIN, CHANNEL_WORKER

application = ProtocolTypeRouter({
    # Client-facing consumers.
    'websocket': URLRouter([
        # To change the prefix, you can import ClientConsumer in your custom
        # Channels routing definitions instead of using these defaults.
        path('ws/<slug:subscriber_id>', ClientConsumer),
    ]),

    # Background worker consumers.
    'channel': ChannelNameRouter({
        CHANNEL_MAIN: MainConsumer,
        CHANNEL_WORKER: WorkerConsumer,
    })
})Also,urls.pyneed to be updated to include some additional paths:urlpatterns = [
  # ...
  url(r'^api/queryobserver/', include('rest_framework_reactive.api_urls')),
  # ...
]RunIn addition to running a Django application server instance, you need to also run a
separate observer worker process (or multiple of them). You may start it by running:python manage.py runworker rest_framework_reactive.main rest_framework_reactive.worker
Package: djangorestframework-recaptcha
===============================Django REST framework reCAPTCHA===============================.. image:: https://badge.fury.io/py/djangorestframework-recaptcha.svg:target: https://badge.fury.io/py/djangorestframework-recaptcha.. image:: https://travis-ci.org/Maximilien-R/django-rest-framework-recaptcha.svg?branch=master:target: https://travis-ci.org/Maximilien-R/django-rest-framework-recaptcha.. image:: https://coveralls.io/repos/github/Maximilien-R/django-rest-framework-recaptcha/badge.svg?branch=master:target: https://coveralls.io/github/Maximilien-R/django-rest-framework-recaptcha?branch=master.. image:: https://readthedocs.org/projects/django-rest-framework-recaptcha/badge/?version=latest:target: https://django-rest-framework-recaptcha.readthedocs.io/en/latest/?badge=latest:alt: Documentation StatusDjango REST framework reCAPTCHA provides you a serializer field to handle andvalidate Google reCAPTCHA response.Documentation-------------The full documentation is at https://django-rest-framework-recaptcha.readthedocs.io.Requirements------------* Python: 2.7, 3.4, 3.5, 3.6, 3.7* Django: 1.10, 1.11, 2.0, 2.1* Django REST framework: 3.4, 3.5, 3.6, 3.7, 3.8, 3.9Installation------------To install Django REST framework reCAPTCHA, run this command in your terminal:.. code-block:: console$ pip install djangorestframework-recaptchaThis is the preferred method to install Django REST framework reCAPTCHA, as itwill always install the most recent stable release.If you don't have `pip`_ installed, this `Python installation guide`_ can guideyou through the process... _pip: https://pip.pypa.io.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/Once the ``djangorestframework-recaptcha`` installed, add it to your``INSTALLED_APPS``:.. code-block:: pythonINSTALLED_APPS = (..."rest_framework_recaptcha",...)Next, register yourself and obtain your reCAPTCHA credentials athttps://www.google.com/recaptcha/admin.Finally, copy/paste your Google reCAPTCHA secret key to the``DRF_RECAPTCHA_SECRET_KEY`` setting:.. code-block:: pythonDRF_RECAPTCHA_SECRET_KEY = "<your_reCAPTCHA_secret_key>"Usage-----To use Django REST framework reCAPTCHA within your project you'll need toimport and add the ``ReCaptchaField`` serializer field into the wantedserializer. For example:.. code-block:: pythonfrom rest_framework import serializersfrom rest_framework_recaptcha import ReCaptchaFieldclass MySerializer(serializers.Serializer):recaptcha = ReCaptchaField()History=======[Unreleased]------------0.2.0 (2018-12-21)------------------Added~~~~~* Django REST framework 3.9, Python 3.7 & Django 2.1.* Set long description content type to reStructuredText.0.1.0 (2018-07-02)------------------Added~~~~~* First release on PyPI.
Package: django-rest-framework-redocs
Django REST Framework ReDocsAutomatically enable live API page for DRF, support both Django1.xand2.x!!Inspired bydjango-rest-framework-docsanddrf-autodocs, thanks for their great work!FeaturesSupport Django 1.8+ ~ 2.x, yah!Automatic API endpoints detectionAutomatic API page generationSupport applicatioin/json or multipart/form-data encodingSupport FileField, so you can test file uploadSupport token authAPI filteringInstallationpip install django_rest_framework_redocsDependenciesFor backend, this project only depends ondjangoanddjango-rest-framework.For frontend:It's aReactSPA, and also uses several UMD builds served byunpkgIt usesbabel-standaloneto transform the embedded JS code on-the-fly, so if you want to modify something you can just edit the code inredocs/templates/index.htmlwithout any prior setup and it should just work!ScreenshotFeature requestJust open an issue to let us know your idea!ContributionsContributions are welcome! We need your help to make this project better!Special ThanksThe automatic endpoint detection algorithm is adapted fromdjango-rest-framework-docsanddrf-autodocs
Package: djangorestframework-registration
OverviewRESTful account registration, activation. This apps is
inspired by django-registration. It uses the same templates as the
django-registration.This package is influenced by the django-registration HMAC workflow.Registration Endpoint is an rest framework APIView,
whereas Activation Endpoint is a django TemplateView.RequirementsPython (3.4)Django (1.8, 1.9)Django REST Framework (3.3)InstallationInstall usingpip…$pipinstalldjangorestframework-registrationExampleInclude the following urls.urlpatterns=[url(r'^api-token-auth/',include('rest_framework_registration.urls')),]the available resources will be available at/api-token-auth/registrations/and/api-token-auth/activations/<key>. See the source code for more detail.TestingInstall testing requirements.$pipinstall-rrequirements.txtRun with runtests.$./runtests.pyYou can also use the excellenttoxtesting tool to run the tests
against all supported versions of Python and Django. Install tox
globally, and then simply run:$toxDocumentationTo build the documentation, you’ll need to installmkdocs.$pipinstallmkdocsTo preview the documentation:$mkdocsserveRunningat:http://127.0.0.1:8000/To build the documentation:$mkdocsbuild
Package: djangorestframework-role-filters
How to installpipinstalldjangorestframework-role-filtersWhy i wrote this project?I want work easily with roles without multiple ifs in codeHow to useCreate role_filters.py with your roles definitionsfromrest_framework_role_filters.role_filtersimportRoleFilterfrom.serializersimportPostSerializerForUserclassAdminRoleFilter(RoleFilter):role_id='admin'classUserRoleFilter(RoleFilter):role_id='user'defget_allowed_actions(self,request,view,obj=None):# This example returns same list both for "global permissions" check,# and for "object" permissions, but different list may be returned# if `obj` argument is not None, and this list will be used to check# if action is allowed during call to `ViewSet.check_object_permissions`return['create','list','retrieve','update','partial_update']defget_queryset(self,request,view,queryset):queryset=queryset.filter(user=request.user)returnquerysetdefget_serializer_class(self,request,view):returnPostSerializerForUserdefget_serializer(self,request,view,serializer_class,*args,**kwargs):fields=('body','created_at','id','serializer_name','title','updated_at','user',)returnserializer_class(*args,fields=fields,**kwargs)Create viewset and override get_role_id methodfromrest_framework_role_filters.viewsetsimportRoleFilterModelViewSetfrom.modelsimportPostfrom.role_filtersimportAdminRoleFilter,UserRoleFilterfrom.serializersimportPostSerializerclassPostViewSet(RoleFilterModelViewSet):queryset=Post.objects.all()serializer_class=PostSerializerrole_filter_classes=[AdminRoleFilter,UserRoleFilter]defget_role_id(self,request):returnrequest.user.role.role_iddefperform_create(self,serializer):serializer.save(user=self.request.user)If role_id is ‘admin’:All actions are allowedThe default queryset is returned -Post.objects.all()The defaultserializer_classis used -PostSerializerThe default viewsetget_serializermethod is usedIf role_id is ‘user’:Only actions ‘create’, ‘list’, ‘retrieve’, ‘update’, ‘partial_update’ are allowedThe queryset is filtered by userTheserializer_class=PostSerializerForUseris usedThe serializer initializing withfieldskwargs  (e.g. for modified serializer as described inDRF: Dynamically modifying fields)Checktestapp examplecode implementation.
Package: django-rest-framework-roles
SimplifiesRole Based Access Controlindjango-rest-framework.Why would I use this?You have more than one type of user in your data model and you have
business logic that diverges depending on the type of user. You do not
want to organize your API by role because that is not very RESTful. You
do not want to manually type out a lot of conditional branching around
user roles.Modeling RequirementsYou must have oneGroupfor each roleAUsercannot belong to more than one of theGroupscorresponding to each roleInstallation$pipinstalldjango-rest-framework-rolesConfigurationVIEWSET_METHOD_REGISTRYA tuple of DRF methods to override.
Defaults to:("get_queryset","get_serializer_class","perform_create","perform_update","perform_destroy",)ROLE_GROUPSA tuple of Group names that correspond 1-to-1 with
user roles. Defaults to:[group.name.lower()forgroupinGroup.objects.all()]It’s recommended to defineROLE_GROUPSinsettingsto avoid
a database lookup on every request.UsageAdd the mixin to any ViewSet:fromdrf_roles.mixinsimportRoleViewSetMixinclassMyViewSet(RoleViewSetMixin,ModelViewSet):# ...For each of the methods specified inVIEWSET_METHOD_REGISTRYa
role-scoped method will be generated on your ViewSet.ParameterizingFor example, let’s say you have three groups namedTakers,Leavers&Gods. Let’s also say you included"get_queryset"in theVIEWSET_METHOD_REGISTRY.When aTakeruser hits an endpont on the ViewSet, the call toget_querysetwill be rerouted to a call toget_queryset_for_takers.When aLeaveruser hits an endpont on the ViewSet, the call toget_querysetwill be rerouted to a call toget_queryset_for_leavers.When aGoduser hits an endpont on the ViewSet, the call toget_querysetwill be rerouted to a call toget_queryset_for_gods.You can implement each of these methods on your ViewSet to return a
different queryset for each type of user.Not ParameterizingYou can alsonotimplement one or more of these methods, in which case
the default call will be executed. For example, with our same set of
groups and with"get_serializer_class"included in the role
registry, let’s say you did not implementget_serializer_class_for_takers. When aTakeruser hits an
endpoint on the ViewSet, the default implementation ofget_serializer_classwill be executed and returnserializer_class.In this case, you would want to be sure that you have aserializer_classdefined on your ViewSet! Otherwise Django REST
Framework will complain. It is a good idea to always define a defaultquerysetandserializer_classwith least privilege (e.g:
Model.objects.none()).RoadmapSome projects require even further parameterization. For example, you may need
to use a differentserializer_classdepending on the user’sroleandtherequest method.There may be a more pleasant way to express the parameterization in code. For
example, it may be more pleasing to use nested classes instead of renaming the
methods.Further ReadingRole-Based Access Control with Django Rest FrameworkComputer Lab
Package: djangorestframework-security-filters
How to installpipinstallpipinstalldjangorestframework-security-filtersWhy i wrote this project?I want work easily with roles without multiple ifs in codeHow to useCreate role_filters.py with your roles definitionsfromrest_framework_role_filters.role_filtersimportRoleFilterfrom.serializersimportPostSerializerForUserclassAdminRoleFilter(RoleFilter):role_id='admin'classUserRoleFilter(RoleFilter):role_id='user'defget_allowed_actions(self,request,view,obj=None):# This example returns same list both for "global permissions" check,# and for "object" permissions, but different list may be returned# if `obj` argument is not None, and this list will be used to check# if action is allowed during call to `ViewSet.check_object_permissions`return['create','list','retrieve','update','partial_update']defget_queryset(self,request,view,queryset):queryset=queryset.filter(user=request.user)returnquerysetdefget_serializer_class(self,request,view):returnPostSerializerForUserdefget_serializer(self,request,view,serializer_class,*args,**kwargs):fields=('body','created_at','id','serializer_name','title','updated_at','user',)returnserializer_class(*args,fields=fields,**kwargs)Create viewset and override get_role_id methodfromrest_framework_role_filters.viewsetsimportRoleFilterModelViewSetfrom.modelsimportPostfrom.role_filtersimportAdminRoleFilter,UserRoleFilterfrom.serializersimportPostSerializerclassPostViewSet(RoleFilterModelViewSet):queryset=Post.objects.all()serializer_class=PostSerializerrole_filter_classes=[AdminRoleFilter,UserRoleFilter]defperform_create(self,serializer):serializer.save(user=self.request.user)If role_id is ‘admin’:All actions are allowedThe default queryset is returned -Post.objects.all()The defaultserializer_classis used -PostSerializerThe default viewsetget_serializermethod is usedIf role_id is ‘user’:Only actions ‘create’, ‘list’, ‘retrieve’, ‘update’, ‘partial_update’ are allowedThe queryset is filtered by userTheserializer_class=PostSerializerForUseris usedThe serializer initializing withfieldskwargs  (e.g. for modified serializer as described inDRF: Dynamically modifying fields)Checktestapp examplecode implementation.
Package: djangorestframework-serializer-extensions
Django REST framework serializer extensionsA collection of useful tools to DRY up your Django Rest Framework serializersFull documentation:http://django-rest-framework-serializer-extensions.readthedocs.io/OverviewSerializer extensions reduces the need forvery similarserializers, by
allowing the fields to be defined on aper-view/requestbasis. Fields can be
whitelisted, blacklisted, and child serializers can be optionally expanded.
Whatever fields you choose to use, your querysets can beoptimized
automaticallyto make the fewest database calls possible.Support forHashIdsis
also provided. If you're currently exposing your internal IDs over a public
API, we suggest you consider switching to HashIds instead.:star: Lovingly open-sourced byHousekeep.RequirementsTested against:Python (3.6, 3.7, 3.8)Django(2.1, 2.2, 3.0)Django REST Framework(3.9, 3.10, 3.11)HashIds(>1.0)InstallationInstall usingpip:$pipinstalldjangorestframework-serializer-extensionsAnd addrest_framework_serializer_extensionsto yourINSTALLED_APPSsetting:INSTALLED_APPS=(...'rest_framework_serializer_extensions')Basic UsageTo activate the serializer extensions, add theSerializerExtensionsMixinto your serializers:# serializers.pyfromrest_framework.serializersimportModelSerializerfromrest_framework_serializer_extensions.serializersimportSerializerExtensionsMixin...classOwnerSerializer(SerializerExtensionsMixin,ModelSerializer):classMeta:model=models.Ownerfields=('id','name')expandable_fields=dict(organization=OrganizationSerializer,cars=dict(serializer=SkuSerializer,many=True))And add theSerializerExtensionsAPIViewMixinto your API views:fromrest_framework.genericsimportRetrieveAPIViewfromrest_framework_serializer_extensions.viewsimportSerializerExtensionsAPIViewMixinclassRetriveOwnerAPIView(SerializerExtensionsAPIViewMixin,RetrieveAPIView):...ExamplesSerializer extensions allows your API to re-use your serializers to fit a
variety of use cases. The examples shown below use query parameters to
modify the response, but individual views can interact with your serializers
in much the same way.>>>GET/owner/x4F/{"id":'x4F',"name":'tyrell',"organization_id":'kgD'}>>>GET/owner/x4F/?expand=organization{"id":'x4F',"name":'tyrell',"organization_id":'kgD',"organization":{"id":"kgD","name":"E Corp"}}>>>GET/owner/x4F/?expand=cars__model&exclude=name{"id":'x4F',"organization_id":'kgD',"cars":[{"id":"wf9","variant":"P100D","model":{"id":"ncX","name":"Model S"}}]}>>>GET/owner/x4F/?expand=cars&only=cars__variant{"cars":[{"variant":"P100D",}]}TestingInstall testing requirements.$pipinstall-rrequirements.txtRun with runtests.$./runtests.pyYou can also use the excellenttoxtesting tool to run the
tests against all supported versions of Python and Django. Install tox
globally, and then simply run:$toxDocumentationTo build the documentation, you’ll need to installmkdocs.$pipinstallmkdocsTo preview the documentation:$mkdocsserve
Runningat:http://127.0.0.1:8000/To build the documentation:$mkdocsbuild
Package: djangorestframework-serializer-mixins
Mixins for Django Rest Framework SerializerHow to installpipinstalldjangorestframework-serializer-mixinsHow to useAssume you have a Post model:# testapp/models.pyfromdjango.confimportsettingsfromdjango.dbimportmodelsclassPost(models.Model):user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,related_name='posts')title=models.CharField(max_length=128)body=models.TextField()created_at=models.DateTimeField(auto_now_add=True)updated_at=models.DateTimeField(auto_now=True)def__str__(self):returnself.titleclassMeta:ordering=['-created_at']Write DynamicPostSerializer with DynamicFieldsMixin:# testapp/serializers.pyfromrest_frameworkimportserializersfromrest_framework_serializer_mixinsimportDynamicFieldsMixinfrom.modelsimportPostclassDynamicPostSerializer(DynamicFieldsMixin,serializers.ModelSerializer):classMeta:model=Postfields=('body','created_at','id','title','updated_at','user',)read_only_fields=('id','user',)Now, you can define fields and read_only_field like this:>>>fromdjango.contrib.auth.modelsimportUser>>>fromtestapp.modelsimportPost>>>fromtestapp.serializersimportDynamicPostSerializer>>>user=User.objects.create_user('user','user@email.com','123456')>>>post=Post.objects.create(user=user,title='My Title',body='My Body')>>>data=DynamicPostSerializer(post)# return fields and read_only_fields from Meta>>>serializer=DynamicPostSerializer(post)# return fields and read_only_fields from Meta>>>serializer.data{'body':'My Body','created_at':'2018-02-14T14:15:29.772209Z','id':1,'title':'My Title','updated_at':'2018-02-14T14:15:29.772312Z','user':1}>>>serializer=DynamicPostSerializer(post,fields=('title','body'))# return only title and body fields>>>serializer.data{'body':'My Body','title':'My Title'}>>>serializer=DynamicPostSerializer(post,read_only_fields=('title','body'),data={'title':'New Title','body':'New Body'})# set title and body as read_only_fields>>>serializer.is_valid()True>>>serializer.save()<Post:MyTitle>>>>serializer.data{'body':'My Body','created_at':'2018-02-14T14:15:29.772209Z','id':1,'title':'My Title','updated_at':'2018-02-14T14:19:14.838001Z','user':1}# title and body don't change
Package: djangorestframework-simplejwt-captcha
Simple JWTAbstractSimple JWT is a JSON Web Token authentication plugin for the Django RESTFrameworkFor full documentation, visit django-rest-framework-simplejwt.readthedocs.io二次开发的Simple JWTInstallationYou can use this command to install this package:pip3 install djangorestframework_simplejwt_captchaUsagefrom rest_framework_simplejwt.views import TokenObtainPairView,TokenRefreshView,ImageInfo

urlpatterns = [
    path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('api/images_captcha/',ImageInfo.as_view(), name='images_captcha'),

]api/images_captcha 是获取图片base64和uuidapi/token/是登录获取jwt传入4个参数-username-password-uuid          # 获取上一个api 的uuid-captcha       # 图片验证码api/token/refresh     刷新tokenFor more information, see here验证码有效期是120秒
Package: djangorestframework-simplejwt-mongoengine
Simple JWT MongoEngineSimple JWT MongoEngine is a JSON Web Token authentication plugin for theDjango REST Frameworkwhich to be compatible withMongoEngine. It is re-written fromSimple JWT.For the documentation, visithttps://djangorestframework-simplejwt-mongoengine.readthedocs.io.AuthorsSimple JWT MongoEngine was created byĐỗ Ngọc Ngoạn (aka Ngoan Do).LicenseCopyright (C) 2021  Đỗ Ngọc Ngoạn (aka Ngoan Do)This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.Also add information on how to contact you by electronic and paper mail.You should also get your employer (if you work as a programmer) or school,
if any, to sign a “copyright disclaimer” for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.SeeLICENSEto see the full text.
Package: djangorestframework-simplejwt-sso
Simple JWT SSO is plugin to Django REST Framework Simple JWT that enables
Single sign-on in a microservice-oriented environment.RequirementsPython (3.6, 3.7, 3.8)Django (2.0, 2.1, 2.2, 3.0)Django REST Framework (3.8, 3.9, 3.10)Django Rest Framework SimplejwtInstallationSimple JWT can be installed with pip:pip install djangorestframework_simplejwt_sso