Saravanan666/pypi-org huggingface dataset:
Package: django-rest-sessions
Rest based sessions backend for Django.PrerequisitesThis backend relies onrest-sessionsfor storing and managing sessions.
Npm rest-sessions needs to be running and accessible at SESSION_URL.RequirementsThis package relies on therequestspackage. Make sure it is installed in your Django project:pip install requestsInstallInstall with pip:pip installdjango-rest-sessionsConfigureAfter installing django-rest-sessions you must add a few settings to your
settings.pyAddrest_sessionsas your session engine:SESSION_ENGINE = 'rest_sessions'Adddjango.contrib.sessions.middleware.SessionMiddlewareto
MIDDLEWARE_CLASSESAdd the name of the session cookie for Django’s session middleware:SESSION_COOKIE_NAME = 'session-cookie'Add the path where npm rest-sessions is running:SESSION_URL = 'example.com/path/to/rest-sessions'Add the app that is used in npm rest-sessions:SESSION_APP = 'mywebapp'UsageThis session backend is mostly intended to be used in a microservice
architecture and thus does not handle creating sessions since npm rest-sessions
requires a user key so it would only be possible to create a session within
the microservice that takes care of the users for your application.
Because this is intended to add sessions to requests to all microservices
written in Django it is more applicable to create sessions once a user logs in
or requests a web page and use this for services handling RESTful requests that
said web page makes.TestingTo run tests the following packages are needed:djangorequestsrequests_mockInstall them with:pip install -r requirements.txtRun the tests with:python setup.py testorpython setup.py xml_testwhich generates an xml report
Package: django-rest-signature
django-rest-signature是一个多站点的网站签名Overview这个包支持Django REST framework.Requirementspython(3.4)Django(1.8)Django REST Framework (3.1.0)PyJwt只在上述环境中测试过Installationinstall using pip$pipinstalldjango-rest-signatureSettings在INSTALLED_APPS 中增加‘rest_signature’.INSTALLED_APPS=(....'rest_signature',)在MIDDLEWARE_CLASSES 中 AuthenticationMiddleware之前增加‘rest_signature.middleware.SignatureMiddleware’MIDDLEWARE_CLASSES=(...'rest_signature.middleware.SignatureMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware',...)Usage通过request.site获取 site 对象Issue对GET和非GET请求未处理
Package: django-rest-sms-auth
Django rest sms authAuthentication usersChange phone numberProviders:MegafonSmsaeroTwilioRequirementsPython >= 3.0Django >= 2.0CeleryDjangorestframeworkDjango-phonenumber-fieldConceptClient send phone numbersmsauthvalidate and createsms codesms providersend digit codeClient send{sms code + phone number}Response info (jwt token)NotesLibrary usecelery.InstructionTo usetwilioinstallextra libraryYou may add your own provider inherit fromSMSProviderInstallationpip install django-rest-sms-authIf you want to usetwilio:pip install twiliosettings.pyINSTALLED_APPS=['django.contrib.admin','django.contrib.auth',...'sms_auth',# you have to add this'sms_auth.providers.twilio'# if twilio provider'sms_auth.providers.megafon'# if megafon provider]SMS_AUTH_SETTINGS={"SMS_CELERY_FILE_NAME":"run_celery",# your system celery file,"SMS_AUTH_SUCCESS_KEY":"jwt_token",# property from user model"SMS_AUTH_PROVIDER_FROM":"ex: +7542222222",# sms signature# If twilio"SMS_AUTH_ACCOUNT_SID":"Twilio SID""SMS_AUTH_AUTH_TOKEN":"Twilio token"# If another provider"SMS_AUTH_PROVIDER_LOGIN":"SMS provider login""SMS_AUTH_PROVIDER_PASSWORD":"SMS provider password"}Addceleryconfiguration file:Instructionrun migrations:pythonmanage.pymakemigrationssms_auth&&pythonmanage.pymigrateurls.pypath('auth/',include('sms_auth.api.urls'))Library is ready to use.UsageSign-in / sign-up:POST /auth/sign-in/
body: {
    "phone_number":"user phone number"
}
result: 200/400 responseCode validation and get token:POST /auth/auth/
body: {
    "phone_number":"user phone number",
    "code":sms_code
}
result: 200/400 response (with token)Change phone number:POST /auth/change-phonenumber/
body: {
    "new_phone_number":"user new phone number"
}
result: 200/400 responseAfter your call previous endpoint:/auth/authand send new phone number with code.ExtraTo clear all expired sms codespythonmanage.pyclear_expiredAdditional settings:"SMS_AUTH_CODE_LEN": int (default: 4)
"SMS_DEBUG": bool (default: False)
"SMS_DEBUG_CODE": int (when debug, default 1111)
"SMS_USER_FIELD": "username" 
"SMS_TIMELIFE": 60 # life time of each sms code
"SMS_CODE_NOT_FOUND": "Some text when code not found"
"SMS_WAIT_TIME": "Some text when sms was sended"
"SMS_REQUEST_SUCCESS": "Some text when success phone validatioin and sms sended to user",
"SMS_AUTH_DEBUG_PHONE_NUMBER": phone number with always SMS_DEBUG_CODE
Package: django-rest-survey
Dynamic and custom surveys for any objects in your databaseDocumentationThe full documentation is athttps://django-rest-survey.readthedocs.io.QuickstartInstall Django REST Survey:pip install django-rest-surveyAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'rest_survey.apps.RestSurveyConfig',...)Add Django REST Survey’s URL patterns:fromrest_surveyimporturlsasrest_survey_urlsurlpatterns=[...url(r'^',include(rest_survey_urls)),...]FeaturesTODORunning TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.0 (2017-06-06)First release on PyPI.
Package: django-rest-swagger-master
Django RestFramework Swagger MasterSummaryDjangoDjango EnvironDjango TemplateDjango RestFrameworkDjango RestFramework SwaggerSave your time and please PR if more feature for django template.EnvironmentInstall Server Firewallsudo ufw enable
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw allow ftp
sudo ufw statusInstall Python Environmentsudo apt-get install python3-dev virtualenvInstall Database Service
Mysqlinstallsudo apt-get install build-essential mysql-server libmysqlclient-devservicesudo ufw allow mysql
sudo systemctl start mysql
sudo systemctl enable mysqlsetting root usersudo -u root mysqlUSE mysql;
UPDATE user SET authentication_string=PASSWORD("rootpassword") WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
exitsetting new userCREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON.TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
exitmysql -u myuser -pCREATE DATABASE mydb;Postgresqlinstallsudo apt-get install libpq-dev postgresql postgresql-contribservicesudo ufw allow postgresql
sudo systemctl start postgresql
sudo systemctl enable postgresqlsetting root usersudo -u postgres psql
\password sde
\qsetting new userCREATE DATABASE mydb;CREATE USER myuser WITH PASSWORD 'mypassword';
ALTER ROLE myuser SET client_encoding TO 'utf8';
ALTER ROLE myuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE myuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;InstallationInstallDjango Projectsetting secret keymv mysite/_secret_settings.py mysite/secret_settings.py
nano mysite/secret_settings.pyinstall virtual environmentvirtualenv -p python3 venv
source venv/bin/activateinstall django projectpip install -r requirement.txt
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py collectstatictesting django projectsudo ufw allow 8000
python manage.py runserver 0:8000DeploymentInstall Gunicornpip install gunicorn
gunicorn --bind 0.0.0.0:8000 mysite.wsgisudo nano /etc/systemd/system/gunicorn.service[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/mysite
ExecStart=/home/ubuntu/django-rest-swagger-master/mysite/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/mysite/mysite.sock mysite.wsgi:application

[Install]
WantedBy=multi-user.targetsudo systemctl restart gunicorn
sudo systemctl enable gunicornInstall Nginxsudo apt-get install nginx
sudo nano /etc/nginx/sites-available/mysiteserver {
    listen 80;
    server_name server_domain_or_IP;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ubuntu/django-rest-swagger-master;
    }
    location /static/ {
        root /home/ubuntu/django-rest-swagger-master;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/ubuntu/django-rest-swagger-master/mysite.sock;
    }
}sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
sudo ufw allow 'Nginx Full'
Package: django-rest-swagger-swaggerdoc
Django REST Swagger 2.0 has changed drastically. For example, you may not put a return code in YAML files.
This package provides functions to inject a swagger style yaml data to the django-rest-swagger’s data.How to use itAdd rest_framework_swagger to your INSTALLED_APPS settingsettings.py:INSTALLED_APPS = (
    ...
   'rest_framework_swagger',
)You create a swagger style yaml file.This YAML file is swagger style../api_test_doc.yml:get:
  description: test document
  responses:
    200:
      description: success
    400:
      description: bad request
      schema:
        type: json
      headers:
        Content-Type: application/jsonYou create api view function or ViewClass.The swaggerdoc decorator to specify the relative path from the file
the view callable is defined.views.py:from rest_framework.decorators import api_view
from rest_framework.views import APIView

from django_rest_swagger_swaggerdoc import swaggerdoc

@swaggerdoc('api_test_doc.yml')
@api_view()
def example_view(request):
    pass

class ExampleView(APIView):
    @swaggerdoc('./api_test_doc.yml')
    def get(self, request):
        passYou create document schema view.Use django_rest_swagger_swaggerdoc.renderers.SwaggerAdditinalDocRenderer.
DO NOT USE rest_framework_swagger.renderers.OpenAPIRenderer.views.py:from rest_framework_swagger.renderers import SwaggerUIRenderer
from rest_framework.decorators import api_view, renderer_classes
from rest_framework import response, schemas

from django_rest_swagger_swaggerdoc.renderers import SwaggerAdditinalDocRenderer


@api_view()
@renderer_classes([SwaggerUIRenderer, SwaggerAdditinalDocRenderer])
def schema_view(request):
    generator = schemas.SchemaGenerator(title='Pastebin API')
    return response.Response(generator.get_schema(request=request))See example project:https://github.com/TakesxiSximada/django-rest-swagger-swaggerdoc/tree/master/examplesInstall$ pip install django-rest-swagger-swaggerdocIt is depends on djangorestframework(>= 3.4.7).
If older than version 3.7.4, it may not be able to correctly resolve the YAML path.OtherPyPI:https://pypi.python.org/pypi/django-rest-swagger-swaggerdocGithub:https://github.com/TakesxiSximada/django-rest-swagger-swaggerdocCircleCI:https://circleci.com/gh/TakesxiSximada/django-rest-swagger-swaggerdocCodeCov:https://codecov.io/gh/TakesxiSximada/django-rest-swagger-swaggerdoc
Package: django-rest-tables
Create dynamic tables with Angular using your Django Rest Framework API.If you use Django Rest Framework, get a representation of your results dynamic and easy to use and extend. Features
include:Self-construction.Pagination.Filter by columns.Sort by columns.Change the field representation.Basic usageCreate a table class including your Django Rest Framework (DRF) ViewSet:# myapp/api.py# ------------classMyTable(Table):classMeta:view_set=MymodelViewSet# DRF ViewSetAdd it to your view context:# myapp/views.py# --------------defmy_view(request):returnrender(request,'myapp/mytable.html',{'table':MyTable()})Add it to your template:{# myapp/templates/myapp/mytable.html #}{# ---------------------------------- #}{%loadrest_tables%}{%rest_tabletable%}....<scriptsrc="//unpkg.com/angular@1.3.12/angular.min.js"type="text/javascript"></script><scriptsrc="//unpkg.com/ng-table@3.0.1/bundles/ng-table.min.js"type="text/javascript"></script><scriptsrc="{%static'rest_tables/src/js/rest_tables.js'%}"type="text/javascript"></script>It’s all!
Package: django-rest-token-expiry
Django REST Token ExpiryDjango REST Token Expiry is a Python package designed to add token expiration functionality to Django REST Framework's default token authentication system. This package allows developers to set expiry durations for authentication tokens, enhancing security by automatically invalidating tokens after a specified period.
InstallationYou can install Django REST Token Expiry via pip:pipinstalldjango-rest-token-expiryUsageDefineAUTHENTICATION_TOKEN_EXPIRYin yoursettings.pywith the desired time delta value for token expiration:fromdatetimeimporttimedeltaAUTHENTICATION_TOKEN_EXPIRY=timedelta(days=7)# Example: Token expires in 7 daysUpdate theDEFAULT_AUTHENTICATION_CLASSESsetting in yourREST_FRAMEWORKsettings to includeExpiringTokenAuthentication:REST_FRAMEWORK={'DEFAULT_AUTHENTICATION_CLASSES':['django_rest_token_expiry.authentication.ExpiringTokenAuthentication'# ... other authentication classes]}Now, the authentication tokens generated by Django REST Framework will have expiration based on the duration specified inAUTHENTICATION_TOKEN_EXPIRY.
ContributingContributions are welcome! If you'd like to contribute to this project, please fork the repository and submit a pull request with your changes.
LicenseThis project is licensed under the MIT License - see the LICENSE file for details.
Package: django-rest-tools
Install last stable version from pypipipinstalldjango-rest-toolsInstall development versionpipinstallhttps://github.com/quiqueporta/django-rest-tools/tarball/masterFiltersNearToPointFilterviews.py:fromdjango_rest_tools.filtersimportNearToPointFilterclassLocationsList(generics.ListAPIView):queryset=Location.objects.all()serializer_class=LocationListSerializerfilter_backends=(NearToPointFilter,)point_field_filter='location'We can then filter in the URL.eg:./location/?max_distance=40&lat=-40.4862&long=-0.39536FieldsDateToTimeStampFieldmodels.py:classMyModel(models.Model):date=models.DateField()serializers.py:classMySerializer(serializers.ModelSerializer):date=DateToTimeStampField()classMeta:model=MyModelfields=('id','date',)The representation of the serializer is like this:{'id':1,'date':1440626400000}But into the database stores ‘2015-08-27’DateTimeToTimeStampFieldmodels.py:classMyModel(models.Model):date=models.DateTimeField()serializers.py:classMySerializer(serializers.ModelSerializer):date=DateTimeToTimeStampField()classMeta:model=MyModelfields=('id','date',)The representation of the serializer is like this:{'id':1,'date':1440688376}But into the database stores ‘2015-08-27 15:12:56 UTC’
Package: django-rest-tsg
django-rest-tsgA TypeScript code generator for Django Rest Framework, which saved your hand-working and guaranteed consistency
between Python codes and modern frontend codes written in TypeScript.FeaturesIt generates TypeScript codes from following Python types.Django REST Framework serializers: manual working onSerializer,ModelSerializerderived from Django ORM models,DataclassSerializerviadjangorestframework-dataclasses.Python dataclasses: Classes decorated bydataclasses.dataclass.Python enums: Subclasses ofenum.Enum.It also supports nested types and composite types.RequirementsPython >=3.9Django >=3.0Django REST Framework >=3.12UsageInstall usingpip.$pipinstalldjango_rest_tsgPut atsgconfig.pyfile with build tasks into your django project’s root.fromdjango.confimportsettingsfromdjango_rest_tsg.buildimportbuildBUILD_DIR=settings.BASE_DIR/"app/src/core"BUILD_TASKS=[build(Foo),build(BarSerializer,{"alias":"Foobar"}),]Adddjango_rest_tsgto yourINSTALLED_APPS.INSTALLED_APPS=[..."django_rest_tsg"]Runbuildtypescriptcommand onmanage.py.$pythonmanage.pybuildtypescriptOr you can switch to another place.$pythonmanage.pybuildtypescript--build-dir/somewhere/you/cannot/explainExamplesInput: SerializerclassPathSerializer(serializers.Serializer):name=serializers.CharField()suffix=serializers.CharField()suffixes=serializers.ListField(child=serializers.CharField())stem=serializers.CharField()is_directory=serializers.BooleanField(source="is_dir")size=serializers.IntegerField(source="stat.st_size")Output: InterfaceexportinterfacePath{name:string;suffix:string;suffixes:string[];stem:string;isDirectory:boolean;size:number;}There are more examples intest cases.Build OptionsAll options are listed in the table below.NameContextValuealiasAllstrbuild_dirAllstr|Pathenforce_uppercaseEnumbool(False)
Package: django-rest-tzolkin
=============================Django Rest API for convert Mesoamerican Long Count calendar`<http://en.wikipedia.org/wiki/Mesoamerican_Long_Count_calendar>`_to Gregorian `http://en.wikipedia.org/wiki/Gregorian_calendar`_ datesInstallation------------Install using ``pip``:$ pip install django-rest-tzolkin...or clone the project from github:$ git clone https://github.com/dimddev/django-rest-tzolkinDjango and Django-Rest-Framework are required packagesConfig------put url(r'^API', include('tzolkin.urls')) into your urls.pystart/ or restart your test serverUsage-----Tzolkin2Gregorian Converter means that will convert long count date in formatbaktun.katun.tun.uinal.kin (13.0.0.0.0) to gregorian date 2012-12-21 (Y-m-d)example url and long count:http://your_test_ip/API/v1/ancient/calendars/mayan/tzolkin2gregorian?date=13.0.0.0.0JSON resultGregorian2Tzolkin Converter means that will convert gregorian date 2012-12-21(Y-m-d) (supported formats are Y/m/d, Y-m-d, Ymd) to Long count 13.0.0.0.0,includind Haab date and of course The Tzolkin or Sacred Mayan Calendarexample url and gregorian date in format Ymdhttp://your_test_ip/API/v1/ancient/calendars/mayan/gregorian2tzolkin?date=20011012JSON resultSo that's all, have fun with The Tzolkin or Sacred Mayan Calendar : )
Package: django-rest-urltoken-auth
Django REST URL Token AuthenticationSimple extension for Django REST Framework to allow for simple url token authentication. Adds
an authentication option for passing a token key as an url parameter:?token=sometokenand
allows for managing tokens through the admin (similar to Tastypie).This could be useful for example when needing to share some data through a simple API with an
external group where you don't want to make a user account for the group on your application.By default, the token only gives READ ONLY permission to requests, but this can be adjusted to
allow url token authentication for all requests.InstallationAdd "django_rest_urltoken_auth" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [
    ...
    'django_rest_urltoken_auth',
]Runpython manage.py migrateto create the apps models.Quick startCreate URL API tokens in the admin:/admin/django_rest_urltoken_auth/urltokens/Set permission of the DRF view/viewset to IsURLTokenAuthenticatedfrom django_rest_urltoken_auth.permissions import IsURLTokenAuthenticated

...
# viewsets.py

class ExampleViewSet(viewsets.ReadOnlyModelViewSet):
    permission_classes = (IsURLTokenAuthenticated,)
    queryset = Example.objects.all()This view can now be accessed by adding?token=<url_token>to the request url.Optional configurationBy default the url parameter used for the authentication token istoken. This can be
adapted by overriding the settingDRF_URLTOKEN_PARAM. For example:# settings.py

DRF_URLTOKEN_PARAM = "secret"would lead to authentication the API using?secret=<url_token>as url parameter.If you want to allow url token authentication on all requests methods
(not just read only methodsGET,HEAD,OPTIONS), then add to your settings:DRF_URLTOKEN_READ_ONLY=FalseRunning testsFor running the tests using pytest:pip install pytestpytest --pyargs django_rest_urltoken_auth.tests
Package: django-rest-utils-mosoti
=====rest_utils=====rest_utils is a simple Django app tha that provides resusable utils for a django rest project.Detailed documentation is in the "docs" directory.Quick start-----------1. Add "rest_utils" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'rest_utils',]2. Use the resusables in views, and renderers.py files in your project.
Package: django-rest-vault
django-rest-vaultApi data decryption and encryption support for Django REST FrameworkRequirementsPython (3.6+)Django (2.2.16+)Django REST Framework (3.10.3+)InstallationInstall usingpippipinstalldjango-rest-vaultUsageAddrest_framework_vaulttoINSTALLED_APPSandREST_FRAMEWORKINSTALLED_APPS = (
  ...
  'rest_framework',       # Django REST Framework
  'rest_framework_vault', # Django REST Vault
  ...
)

REST_FRAMEWORK = {
  'DEFAULT_PARSER_CLASSES': (
    'rest_framework.parsers.JSONParser',
    'rest_framework_vault.parsers.VaultParser',
  ),
  'DEFAULT_RENDERER_CLASSES': (
    'rest_framework.renderers.JSONRenderer',
    'rest_framework_vault.renderers.VaultRenderer',
  ),
}Also add settings forREST_VAULTto your projectsettings.pyREST_VAULT = {
  'SECRET_KEY': b'*Thirty-two byte (256 bits) key*',
  'HTTP_CONTENT_TYPE': 'application/vault',
  'HTTP_ACCEPT': 'application/vault',
  'HTTP_FORMAT': 'vault',
  'USE_TOKEN_AS_KEY': True,
}ExamplesGet Users List (Default - json)curl-uadmin:123456'http://localhost:8000/users/'{"count":1,"next":null,"previous":null,"results":[{"url":"http://localhost:8000/users/1/","username":"admin","email":"admin@example.com","groups":[]}]}Get Users List (vault)curl-uadmin:123456'http://localhost:8000/users/?format=vault6ARyPVxylOavaXFslb/Ab/AiYWsoFqCIu8pJ9bhnGI9zozmRkdWOySt4bI7CY0detuA9RkWhnHMS4/gLIu907E0Z8A0vHP56z493Zkld+UYSS94nk19LDr5TfkOEAQ0+A4C1AgbxlgSWk2XpxpDVZc4Nwm9rXOrP1xpIWXwAUREG520mdPwiR8AYPUpRVExsH7hSKXiasEVczAxPsXVKaamv/WC3CxgMldrIRA==
Package: django-rest-verification
Verification is a Django app to conduct code-based verifications. For any verification,
email or phone, it can be used.Detailed documentation is in the “docs” directory.Quick startAdd “verification” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'verification',
]Write yuor preferred settings in settings file:VERIFICATION = {
    'VERIFICATIONS': [
        {'type': 'email', 'user_model_field': 'is_email_verified'},],

    'CODE_LENGTH': 6,
    'CONTAINS_NUMERIC': True,
    'CONTAINS_UPPER_ALPHABETIC': False,
    'CONTAINS_LOWER_ALPHABETIC': False,
    'LIFE_TIME_SECOND': 0,
    'LIFE_TIME_MINUTE': 3,
    'LIFE_TIME_HOUR': 0,
    'LIFE_TIME_DAY': 0,
    'LIFE_TIME_PENALTY_SECOND': 60,

}2. Inherit from verification.views “BaseGenerateVerificationAPIView” and
“BaseVerifyVerificationAPIView” classes.3. Write your preferred function for sending code and In class that inherits
from “BaseGenerateVerificationAPIView” set it to “send_code_function” variable.Connect your urls to your views.Runpython manage.py migrateto create the verification models.