Saravanan666/pypi-org huggingface dataset:
Package: drf-common-exceptions
drf-common-exceptionsReleaseCICoverageCommon exception for Django REST framework. Provides single generic interface of
returning data structure for any kind of exceptions which are handled by
Django REST framework. Includes error name, path to service with line
where the error occurs and a list of actual error messages
with extended fields info.RequirementsPython (3.6+)Django (1.11.x, 2.0+)Django REST Framework (3.7+)Installation$pipinstalldrf-common-exceptionsUsage examplesYou can define common exception handler for whole project. Just put the
following line to your django settings inside drf section:REST_FRAMEWORK = {
  ...
  "EXCEPTION_HANDLER": "drf_common_exceptions.common_exception_handler",
  ...
}Or use it just for particular view or viewset:fromdrf_common_exceptionsimportCommonExceptionHandlerMixinclassMyView(CommonExceptionHandlerMixin,APIView):passThe output will looks like for example validation error:{"service":"path.to.views.MyView:20","error":"ValidationError","detail":[{"label":"Name","field":"name","messages":["This is required field."]}]}The data structure will be the same for any other errors.DevelopmentInstall poetry and requirements:$curl-sSLhttps://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py|python
$python3-mvenvpath/to/venv
$sourcepath/to/venv/bin/activate
$poetryinstallRun main commands:$maketest$makewatch
$makeclean
$makelintPublish to pypi be default patch version:$makepublishor any level you want:$makepublishminor
Package: drf-complete-autocomplete
DRF complete autocompleteInstallation$ pip install drf-complete-autocomplete
$ pip install drf-complete-autocomplete[django-filter]How to useSettings:from drf_complete_autocomplete.configuration import AutocompleteModelDescription

from my_app.models import MyModel


AUTOCOMPLETE_MODELS = [
    AutocompleteModelDescription(
        api_name='my_model',
        model=MyModel,
        value_field='pk',
        label_field='__unicode__',
        icontains_search_fields=['name'],
        filterset=None,  # django-filter FilterSet
        order_by=['name'],
        distinct=False,
        results_limit=20,
    ),
]Serializer:...
from drf_autocomplete.serializers import WithAutocomplete
...


class SomeModelSerializer(WithAutocomplete, serializers.ModelSerializer):
    ...

    class Meta:
        model = SomeModel
        fields = [
            ...
            'related_to_my_model',
            ...
        ]
        ...
        autocomplete_fields = {
            'related_to_my_model': 'my_model',
        }View:You can importdrf_complete_autocomplete.views.RetrieveAutocompleteResultsApiViewand supply your AUTOCOMPLETE_MODELS
in urls fileRetrieveAutocompleteResultsApiView.as_view(autocomplete_config=AUTOCOMPLETE_MODELS).Or use mixindrf_complete_autocomplete.views.RetrieveAutocompleteResultsMixinto create your own view.LicenseThe DRF complete autocomplete package is licensed under theFreeBSD
License.
Package: drf-complete-metadata
DRF complete metadataAboutThis package provides custom metadata class for Django Rest Framework to enrich data returned by OPTIONS requests in easy way.Installpipinstalldrf-complete-metadataUsageJust set the DEFAULT_METADATA_CLASS option in the REST_FRAMEWORK configuration dict in Django settings.REST_FRAMEWORK={'DEFAULT_AUTHENTICATION_CLASSES':['rest_framework.authentication.TokenAuthentication',],'DEFAULT_PERMISSION_CLASSES':['rest_framework.permissions.IsAuthenticated'],'DEFAULT_METADATA_CLASS':'complete_metadata.ApiMetadata',}LicenseThe DRF complete autocomplete package is licensed under theFreeBSD
License.
Package: drf-compound-fields
OverviewDjango-REST-frameworkserializer fieldsfor compound types.
Django-REST-framework provides the ability todeal with multiple objectsusing themany=Trueoption on serializers. That allows for lists of objects and for fields to be
lists of objects.This package expands on that and provides fields allowing:Lists of simple (non-object) types, described by other serializer fields.Fields that allow values to be a list or individual item of some type.Dictionaries of simple and object types.Partial dictionaries which include keys specified in a list.A quick example:from drf_compound_fields.fields import DictField
from drf_compound_fields.fields import ListField
from drf_compound_fields.fields import ListOrItemField
from drf_compound_fields.fields import ListField
from rest_framework import serializers

class EmailContact(serializers.Serializer):
    email = serializers.EmailField()
    verified = serializers.BooleanField()

class UserProfile(serializers.Serializer):
    username = serializers.CharField()
    email_contacts = EmailContact(many=True)  # List of objects: possible with REST-framework alone
    # This is the new stuff:
    skills = ListField(serializers.CharField())  # E.g., ["javascript", "python", "ruby"]
    name = ListOrItemField(serializers.CharField())  # E.g., "Prince" or ["John", "Smith"]
    bookmarks = DictField(serializers.URLField())  # E.g., {"./": "http://slashdot.org"}
    measurements = PartialDictField(included_keys=['height', 'weight'], serializers.IntegerField())Project infoFree software: BSD licenseDocumentationSource codeIssue trackerCI serverIRC: no channel but see AUTHORS for individual nicks on freenode.Mailing list: None yet, but please log anissueif you want to have discussions about this package.History2.0.0 (2019-09-21)Deprecate Python 2 supportFix #291.0.0 (2016-02-29)Upgrade ListOrItemField and PartialDictField for django-rest-framework 3.0 and beyondRemove ListField and DictField, as they now come with django-rest-framework0.2.2 (2014-08-10)Correct validation behaviors when fields are used in embedded serializers. Also correction to thelistanddicttype checks forNonevalues (#15, #16, #18).Implementinitializeandfield_from_nativeto ensure proper validation in embedded
serializers.Give the fields distinctvalidateandrun_validatorsimplementations that don’t call each
other.Don’t apply thelistanddicttype checks forNonevalues.0.2.1 (2014-04-23)Loosen dependency versionsRemove explicit dependency on DjangoLoosen rest-framework to any version before 30.2.0 (2014-03-16)Documentation (#3)Collect messages of nested errors, instead of error objects (#12)Add ListOrItemField type (#5, #11)Fix PartialDictField validation and handling of badly-typed valuesSwitch project tests to py.test (#10)0.1.0 (2014-03-06)First PyPI release of rest-framework serializer compound-fields (#1). Provides:ListField (#4, #7)DictFieldPartialDictField (#8, #9)
Package: drf-contact
Django REST Framework ContactContact App for Django REST Framework with API Views.Django REST Framework - Contactis a Django App for creating user contacts. It's view are based uponDjango REST Framework's GenericAPIViewand hence it contains a RESTful API views also.I'll like to mention following names for certain contributions:Civil Machines Technologies Private Limited: For providing me platform and
funds for research work. This project is hosted currently withCMTonly.Aditya Gupta: Project Developer. Developed & maintained the code. Author of the project.Himanshu Shankar: Ideation & Project Manager. Currently maintaining the projectInstallationDownload and Install viapippip install drf_contactorDownload and Install viaeasy_installeasy_install drf_contactAdddrf_contactinINSTALLED_APPSINSTALLED_APPS = [
    ...
    'drf_contact',
    ...
]Include urls ofdrf_contactinurls.pyurlpatterns = [
    ...
    path('api/contact/', include('drf_contact.urls')),
    ...
]

# or

urlpatterns = [
    ...
    url(r'^api/contact/', include('drf_contact.urls')),
    ...
]Finally, runmigratecommandpython manage.py migrate drf_contact
Package: drf-coupons
DRF CouponsA django-rest-framework application that provides many varieties of couponsDetailed documentation:
*https://github.com/pstrinkle/drf-couponsQuick startAdd “coupons” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'coupons',
]Include the coupons URLconf in your project urls.py like this:url(r'^', include('coupons.urls')),Runpython manage.py migrateto create the polls models.
Package: drf-cpf-cnpj-validator
Examples:fromrest_frameworkimportserializersfromdrf_cpf_cnpj_validator.validadorsimportcpf_validator,cnpj_validatorclassPersonSerializer(serializers.ModelSerializer):cpf=serializers.Charfield(validators=[cpf_validator])classCompanySerializer(serializers.ModelSerializer):cnpj=serializers.Charfield(validators=[cnpj_validator])Translations:This plugin translate the messages from yourLANGUAGE_CODE,
located in settings.py.Enabled translations:en-USpt-BRes-ES
Package: drf-crud-command
Quick StartAdd "crud_management" to your INSTALLED_APPS setting like this:INSTALLED_APPS = [...
 'crud_management',]Runpython manage.py migrateto create the user modelsYou need to create a url.py and serializers.py file in your applicationsRunpython manage.py generate_crud<your_app_name> <your_model>Start the development server and visithttp://127.0.0.1:8000/to create a new user login register
Package: drf-crud-proxy
This package provides extended Django REST Framework generic views and viewsets that provide the possibility to specify
different serializers for reading the incoming request and presenting the response.This is super handy in situations where you want to, for example, let the user send a ForeignKey attribute,
but present the related object alongside the response instead of only the database ID.RequirementsPython 3.6, 3.7, 3.8, 3.9, 3.10 and 3.11Django 3.2, 4.0, 4.1 and 4.2 (basically works with older versions as well, but they’re EOL)Django REST Framework 3.8 or newer (probably works on any 3.x version)Installationpip install drf-crud-proxyUsageImport the generic views and subclass your own views from them. Specifyrequest_serializer_classand/orresponse_serializer_classto the view (both default to DRF’s ownserializer_classattribute).# api/views.pyfromdrf_crud_proxyimportgenericsfromapp.modelsimportMyModelfromapi.serializersimportMyModelCreateSerializer,MyModelSerializerclassMyModelListCreateView(generics.ProxiedListCreateAPIView):queryset=MyModel.objects.all()request_serializer_class=MyModelCreateSerializerresponse_serializer_class=MyModelSerializerThe incoming request is handled withMyModelCreateSerializerand the response withMyModelSerializer.If you want to customize the data on either situation, overrideget_request_dataand/orget_response_datamethods in the view.The package also supports the so-calledPUT-as-createbehavior that was removed from DRF in its 3.0 release. Note that
the user has to have model permissions for the corresponding create behavior (POSTrequest).NOTE: ThePUT-as-createfunctionality doesn’t have tests (yet).LicenseMITInspirationThis functionality in DRF is something I’ve needed in numerous Django projects, so hopefully this will help someone else
too :)This package has been built on top of the ideas presented by the great vintasoftware’sdrf-rw-serializers(https://github.com/vintasoftware/drf-rw-serializers) package. Thanks!
Package: drf-crypto
DRF CryptoThis package only provides the basic requirements to create a payment system
for any blockchain. It means we will not support any blockchain payment with
this package. The reason is the dynamic nature of the blockchain world. They
change rapidly, and usually, everyone works with a specific blockchain. Also,
there are many different strategies to manage payments on a blockchain. For
example, you may want to verify your transactions with a tag (like a memo), or
maybe you want to create one wallet for each user or each transaction.Installationpipinstalldrf-cryptoOr, if you want the latest version, you can directly install the package from
the source code:pipinstallhttps://github.com/xanigo/drf-crypto/archive/refs/heads/master.zipOr using git:pipinstallgit+ssh://git@github.com/xanigo/drf-crypto.git
Package: drf-custom-permissions
drf-permissionsInstallationpip install drf-custom-permissionsUsageAPIView IsNotAuthenticated permission# views.pyfromrest_framework.viewsimportAPIViewfromdrf_custom_permissionsimportIsNotAuthenticatedclassExampleIsNotAuthenticatedAPIVIew(APIView):permission_classes=(IsNotAuthenticated,)...APIView with HasGroupPermission# views.pyfromrest_framework.viewsimportAPIViewfromdrf_custom_permissionsimportHasGroupPermissionclassExampleIsNotAuthenticatedAPIVIew(APIView):permission_classes=(HasGroupPermission,)permission_groups=('Designers','Developers',)...
Package: drf-custom-related-field
DRF Custom Related FieldThis is a Django REST Framework'sPrimaryKeyRelatedFieldlike field which
allows you to pass custom fields (instead of default pk) to serialize relation.RequirementsPython 3.6+Django 2+djangorestframework 3+Installationpip install drf-custom-related-fieldUsageFor example, we have following model structure:fromdjango.dbimportmodelsclassCompany(models.Model):name=models.CharField(max_length=100)country=models.CharField(max_length=100)defupper_name(self):returnself.name.upper()classAddress(models.Model):street=models.CharField(max_length=255)building=models.CharField(max_length=255)deffull_address(self):returnf'{self.street},{self.building}'classWorkingBuilding(models.Model):capacity=models.IntegerField(default=0)address=models.ForeignKey(Address,on_delete=models.CASCADE)classEmployee(models.Model):username=models.CharField(max_length=100)company=models.ForeignKey(Company,on_delete=models.CASCADE)workplace=models.ForeignKey(WorkingBuilding,null=True,on_delete=models.CASCADE,related_name='employees')And we have following instances:work_address=Address.objects.create(street='Main st.',building='10')workplace=WorkingBuilding.objects.create(capacity=200,address=work_address)company=Company.objects.create(name='Great Inc.',country='US',)employee=Employee.objects.create(username='ckkz',company=company,workplace=workplace)Examples:Map custom field for read onlyclassEmployeeSerializer(serializers.ModelSerializer):company=CustomRelatedField(queryset=Company.objects,field_name='name')classMeta:model=Employeefields=('username','company')serializer=EmployeeSerializer(employee)assertserializer.data['company']==company.name{"username":"ckkz","company":"Great Inc."}Assign new value by custom field (namein this case)classEmployeeSerializer(serializers.ModelSerializer):company=CustomRelatedField(queryset=Company.objects,field_name='name')classMeta:model=Employeefields=('username','company')new_company=Company.objects.create(name='New Company',country='RU')serializer=EmployeeSerializer(employee,data={'company':new_company.name},partial=True)serializer.is_valid(raise_exception=True)serializer.save()employee.refresh_from_db()assertemployee.company_id==new_company.id{"username":"ckkz","company":"New Company"}Usemany=TrueclassWorkingBuildingSerializer(serializers.ModelSerializer):employees=CustomRelatedField(field_name='username',many=True,read_only=True)classMeta:model=WorkingBuildingfields=('capacity','employees')serializer=WorkingBuildingSerializer(workplace)assertlen(serializer.data['employees'])==workplace.employees.count(){"capacity":200,"employees":["ckkz"]}Use nested (dotted) relations and callable model fieldsclassEmployeeSerializer(serializers.ModelSerializer):workplace=CustomRelatedField(source='workplace.address',field_name='full_address',read_only=True)classMeta:model=Employeefields=('username','workplace')serializer=EmployeeSerializer(employee)assertserializer.data['workplace']==employee.workplace.address.full_address(){"username":"ckkz","workplace":"Main st., 10"}
Package: drf-custom-utils
[DRF UTILS][docs]安装pipinstalldrf-custom-utils功能DRF mixin 扩展(不分页返回数据action  单独设置model某个字段或做个字段值  基于action实现)微信模板消息发送封装(提供相关小程序和公众号 AppID和secret以及模板消息ID配置在settings中)与第三方对接相关请求封装
Package: drf-dark-shade
drf-dark-shadeEnhance your Django Rest Framework (DRF) browsing experience with thedrf-dark-shadepackage. This lightweight and easy-to-use extension bring a sleek dark theme to the DRF browsable API, reducing eye strain and providing a modern, visually appealing interface for developers.Deep Forest Theme:Installation:Installdrf-dark-shadepackage usingpiporpoetrypipinstalldrf_dark_shadeAdddrf_dark_shadeto yourINSTALLED_APPSin your Django project's settings.INSTALLED_APPS=[# other packages'rest_framework',# drf required'drf_dark_shade',]Adddrf_dark_shaderenderer toREST_FRAMEWORKconfigREST_FRAMEWORK={'DEFAULT_RENDERER_CLASSES':('rest_framework.renderers.JSONRenderer','drf_dark_shade.renderers.DeepForestBrowsableAPIRenderer',)}All set! now run app and visit your API endpoint.Enjoy Dark 🌃ContributionContributions are welcome!If you encounter issues or want to add new features, feel free to open pull requests.Give a ⭐️ if you find this project interesting and useful!
Package: drf-dark-theme
drf-dark-themeDark themes forDjango REST FrameworkStellar Color PaletteStellar ThemeMoonshine Color PaletteMoonshine ThemeInstallationInstall usingpippip install drf-dark-themeAdd ‘drf_chaos’ to your INSTALLED_APPS settingINSTALLED_APPS = (
    ...
    'drf_dark_theme',
)Add eitherStellarBrowsableAPIRendererorMoonshineBrowsableAPIRenderertoDEFAULT_RENDERER_CLASSESREST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        ...
        'drf_dark_theme.renderers.StellarBrowsableAPIRenderer',
    )
}
Package: drf-debug
DRF DebugA package to tracking your API in django rest framework.Usagepip install drf-debugINSTALLED_APPS=[...'tracking',]python manage.py migrateaddtracking.mixins.LoggingMixinto any DRF view to create a instance ofAPIRequestLogevery time the view is called.# views.pyfromrest_framework.viewsimportAPIViewfromrest_framework.responseimportResponsefromtracking.mixinsimportLoggingMixinclassLoggingView(LoggingMixin,APIView):defget(self,request):returnResponse('with logging')For performance enhancement, explicitly choose methods to be logged usinglogging_methodsattribute:classLoggingView(LoggingMixin,generics.CreateModelMixin,generics.GenericAPIView):logging_methods=['POST','PUT']model=...Moreover, you could define your own rules by overridingshould_logmethod. Ifshould_logevaluates to True a log is created.classLoggingView(LoggingMixin,generics.GenericAPIView):defshould_log(self,request,response):"""Log only errors"""returnresponse.status_code>=400You could define your own handling. For example save on an in-memory data structure store, remote logging system etc.classLoggingView(LoggingMixin,generics.GenericAPIView):defhandle_log(self,request,response):cache.set('my_key',self.log,86400)Or you could omit save a request to the database. For example,classLoggingView(LoggingMixin,generics.GenericAPIView):defhandle_log(self,request,response):"""Save only very slow requests. Requests that took more than a second."""ifself.log['response_ms']>1000:super(LoggingMixin,self).handle_log(request,response)By default drf-debug is hiding the values of those fields['api', 'token', 'key', 'secret', 'password', 'signature']You can complete this list with your own list by putting the fields you want to be hidden in thesensitive_fieldsparameter of your view.classLoggingView(LoggingMixin,generics.CreateModelMixin,generics.GenericAPIView):sensitive_fields=['password','my_secret_field']LinksDownload Source Code:Click HereMy Github Account:Click Here
Package: drf-decorator-router
Decorator Router for Django Rest FrameworkAboutDjango Rest Framework package to quickly route your views with decorators.
Very lightweight and simple code using only Django and Rest Framework as dependencies.Supported VersionsPython 3.6 and aboveDjango >= 2.2Django REST Framework >=3.7.0,<=3.13Installationpipinstalldrf-decorator-routerHow to Usemain_app/routes.pyfromrest_frameworkimportgenerics,viewsetsfromdrf_decorator_routerimportRouter# Declaring the routerrouter=Router("api/v1",namespace="api-v1")example_app/views.py@router.route_view("login","user-login")# /api/v1/login/classLoginView(generics.CreateAPIView):pass@router.route_view("company/<int:company_id>/login","company-user-login")# /api/v1/company/10/login/classLoginForCompanyView(generics.CreateAPIView):pass@router.route_viewset("users","users")# /api/v1/users/classUserViewSet(viewsets.ModelViewSet):passImportant:The decorated view/viewset must be declared or imported in theviews.pyfile, or else it
won't be routed. You can also change the file name from which the views will be loaded by adding aAUTO_ROUTER_MODULESin settings.py. Example:AUTO_ROUTER_MODULES=['decorated_views', 'views'].main_app/urls.pyfrommain_app.routersimportrouterurlpatterns=[router.path]Reversingfromrest_framework.reverseimportreverselogin_view=reverse("api-v1:user-login")user_list=reverse("api-v1:users-list")user_detail=reverse("api-v1:users-detail",(10,))
Package: drfdocs
# [DRF Docs](http://www.drfdocs.com/) [![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![pypi][pypi-image]][pypi-url] [![slack][slack-image]][slack-url]Document Web APIs made with Django Rest Framework. [View Demo](http://demo.drfdocs.com/)![DRFdocs](https://cloud.githubusercontent.com/assets/6333409/13193861/69e82aec-d778-11e5-95c4-77f4ef29e6e5.png)### Supports- Python (2.7, 3.3, 3.4, 3.5)- Django (1.8, 1.9)- Django Rest Framework (3+)### Documentation - Table of contents- [Installation](http://drfdocs.com/installation/)- [Settings](http://drfdocs.com/settings/)- [Extending the template](http://drfdocs.com/templates/)- [Live API Endpoints](http://drfdocs.com/live-api/)- [Contributing & Development](http://drfdocs.com/contributing/)- [Changelog](http://drfdocs.com/changelog/)### Development & Demo ProjectIf you are looking to develop this package with one of your own django projects:pyvenv envenv/bin/pip install -r requirements.txtpip install -e ~/Projects/drf-docs/If you want to use the demo app to work on this package:Included in this repo you can find the demo project(at `/demo`). It is a project with *Django* & *Django Rest Framework* that will allow you to work with this project. For more information on how you can set it up please check the [README.md](demo/README.md) of the demo project.For more information visit [the docs](http://drfdocs.com/contributing/).### InstallationInstall using pip:pip install drfdocsAdd 'rest_framework_docs' to your `INSTALLED_APPS` setting:INSTALLED_APPS = (...'rest_framework_docs',)Finally include the `rest_framework_docs` urls in your `urls.py`:urlpatterns = [...url(r'^docs/', include('rest_framework_docs.urls')),]### SettingsYou can find detailed information about the package's settings at [the docs](http://drfdocs.com/settings/).REST_FRAMEWORK_DOCS = {'HIDE_DOCS': True  # Default: False}### CreditsFirst of all thanks to the [Django](http://www.djangoproject.com/) core team and to all the contributors of [Django REST Framework](http://www.django-rest-framework.org/) for their amazing work. Also I would like to thank [Marc Gibbons](https://github.com/marcgibbons) for his *django-rest-framework-docs* project. Both projects share the same idea, it is just that Marc's is not maintained anymore and does not support DRF 3+ & Python 3.[travis-image]: https://travis-ci.org/ekonstantinidis/django-rest-framework-docs.svg?branch=master[travis-url]: https://travis-ci.org/ekonstantinidis/django-rest-framework-docs[pypi-image]: https://badge.fury.io/py/drfdocs.svg[pypi-url]: https://pypi.python.org/pypi/drfdocs/[codecov-image]: https://codecov.io/github/ekonstantinidis/django-rest-framework-docs/coverage.svg?branch=master[codecov-url]:https://codecov.io/github/ekonstantinidis/django-rest-framework-docs?branch=master[slack-image]: https://img.shields.io/badge/slack-pythondev/drfdocs-e01563.svg[slack-url]: https://pythondev.slack.com