Saravanan666/pypi-org huggingface dataset:
Package: djangomicroframework
Django Micro frameworkMicro framework for Django REST FrameworkRequirementsPython (3.6)Django (2.0, 2.1, 2.2, 3.0)Django REST Framework (3.8, 3.9, 3.10)InstallationMicro Framework can be installed with pippip install djangomicroframeworkThen, go to your django project. Insettings.py:REST_FRAMEWORK = {
    'DEFAULT_PARSER_CLASSES': (
        'rest_framework.parsers.JSONParser',
        'rest_framework.parsers.FormParser',
        'rest_framework.parsers.MultiPartParser'
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'micro_framework.jwt_auth.authentication.JWTTokenUserAuthentication',
    ]
}

from datetime import timedelta
MICRO_FRAMEWORK = {
    'SERVICE_NAME': 'Default',
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
    'ROTATE_REFRESH_TOKENS': False,
    'BLACKLIST_AFTER_ROTATION': True,

    'ALGORITHM': 'HS256',
    'SIGNING_KEY': settings.SECRET_KEY,
    'VERIFYING_KEY': None,
    'AUDIENCE': None,
    'ISSUER': None,

    'AUTH_HEADER_TYPES': ('Bearer',),
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',

    'AUTH_TOKEN_CLASSES': ('micro_framework.jwt_auth.tokens.AccessToken',),
    'TOKEN_TYPE_CLAIM': 'token_type',

    'JTI_CLAIM': 'jti',

    # Custom payload Token
    'ADD_USER_IP_CLAIM': False,
    'USER_IP_CLAIM': 'user_ip',

    'ADD_USER_AGENT_CLAIM': False,
    'USER_AGENT_CLAIM': 'user_agent',

    'VALIDATE_SOURCE_IP': False,
    'HEADER_IP_REMOTE': ['HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'],
    

    # Redis backend
    'REDIS_ENABLE': False,
    'REDIS_HOST': 'localhost',
    'REDIS_PORT': 6379,
    'REDIS_PASSWORD': None,
    'REDIS_DB': 0,
    'REDIS_EXPIRE_TOKEN': False,
}AcknowledgmentsThis project is forked and custom fromhttps://github.com/davesque/django-rest-framework-simplejwt
Package: django-microframework
django-microframeworkDjango microframework allows you for easy synchronization of database entities between multiple django instances.RequirementsPython (3.6, 3.7, 3.8)Django (1.11, 2.0, 2.1, 2.2)Installationpip install django-microframework
python manage.py migrateUsageSenderIn your models.py file:frommicroframework.senderimportconnect_signalsconnect_signals([RegularModel,JSONModel,TreeModel,ForeignKeyModel],'example_sender')In your settings.py:MICROFRAMEWORK_AMQP_URI='pyamqp://guest:guest@172.17.0.5'ListenerCreate service.py file:frommicroframework.handlerimportDjangoObjectHandler,NamekoHandlerMetafromexample.modelsimportRegularModel,JSONModel,TreeModel,ForeignKeyModelclassListenerService(DjangoObjectHandler,metaclass=NamekoHandlerMeta):name="listener_service"sender_name="example_sender"synced_save_models=[RegularModel,JSONModel,TreeModel,ForeignKeyModel]In your settings.py:MICROFRAMEWORK_SERVICE_CLASS="example.service:ListenerService"MICROFRAMEWORK_AMQP_URI='pyamqp://guest:guest@172.17.0.5'And add'microframework'to yourINSTALLED_APPSsetting.INSTALLED_APPS = [
    ...
    'microframework',
]In your manage.py - this needs to be put before anything else in your code:importeventleteventlet.monkey_patch()
Package: django-microservice-request
Django application for make sync requests (REST API) between microservices or external APIs.If you don’t have any microservices yet, you can try to useDjango templateQuickstartInstallationInstall the package$pipinstalldjango-microservice-requestUsage (Google Captcha example)settings.pyGOOGLE_CAPTCHA_URL="https://google.com/recaptcha/api/siteverify"GOOGLE_CAPTCHA_SECRET_KEY=os.environ.get("GOOGLE_CAPTCHA_SECRET_KEY")services.pyfromdjango.confimportsettingsfrommicroservice_request.servicesimportConnectionServiceclassGoogleCaptchaService(ConnectionService):service=settings.GOOGLE_CAPTCHA_URLsecret_key=settings.GOOGLE_CAPTCHA_SECRET_KEYdefvalidate_captcha(self,captcha:str)->dict:params={"secret":self.secret_key,"response":captcha,}response=self.service_response(method="get",params=params)returnresponse.dataserializers.pyfrom.servicesimportGoogleCaptchaServiceclassCaptchaMixinSerializer(serializers.Serializer):captcha=serializers.CharField()defvalidate_captcha(self,captcha:str)->str:service=GoogleCaptchaService()response_data=service.validate_captcha(captcha)ifnotresponse_data.get("success"):raiseserializers.ValidationError("Captcha validation error")returncaptchaclassLoginSerializer(CaptchaMixinSerializer):login=serializers.CharField()password=serializers.CharField()
Package: django-microservices
Django-microservices helps you manage the development and interaction
of microservices built in Django.Use CaseYou are using Django to build an application with a microservices architecture.
You have serveral services that communicate to each over HTTP and each service
is it’s own Django project.  You need to run./manage.py runserver [port]for
each service to bring it up and have the application function when developing.Django-microservices helps by:giving you a single/.manage.py runclustercommand to fire up the development
server for each projectproviding a service discovery API that will allow your services to find one anotherRequirementsDjangoInstallCreate anewvirutual environment and django project alongside the django
projects that make up your micoservices application:$ mkvirutalenv myapp_service_manager
$ pip install django django-microservices psycopg2 # for postgres database
$ django-admin startproject service_manager
$ cd service_managerCreate your service manager database:$ createdb myapp_service_manager  # if using postgresEdit the settings in your new service manager project.  Addmicroservicesto theINSTALLED_APPSadd the database settings:# service_manager/settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    ...
    'microservices',
)

# for postgres database
DATABASES = {
    'default': {
        'ENGINE':   'django.db.backends.postgresql_psycopg2',
        'NAME':     'myapp_service_manager',
        'USER':     'db_user',
        'PASSWORD': 'secret',
        'HOST':     'localhost',
        'PORT':     '5432',
    }
}Create database tables:$ ./manage.py migrateCreate an admin user:$ ./manage.py createsuperuserEdit the root urls file to look like this:# service_manager/urls.py

from django.conf.urls import include, url
from django.contrib import admin

from microservices.admin import services_admin_site

urlpatterns = [
    url(r'^',      include('microservices.urls')),
    url(r'^admin/', include(services_admin_site.urls)),
]UsageIn your service manager project, run./manage.py runclusterthen navigate
tohttp://127.0.0.1:8000.The first time you do this, you won’t see any services registerd.  Click
on the “Admin” link, log in and register services by clicking on “Services”
in the Microservices admin.  Click “Add service” to add each new service
in your app.Now at the index page of the service manager project you will see a list of
services with links to each.For any application that needs to find services in the cluster, add this to
the settings.py file:import requests

SERVICES = requests.get('http://127.0.0.1:8000/services/').json()Then usesettings.SERVICES[service_name]to get the correct IP for any service
in your application.
Package: django-microsoft-auth
Simple app to enable Microsoft Account, Office 365 and Xbox Live authentication
as a Django authentication backend.Free software: MIT licenseDocumentation:https://django-microsoft-auth.readthedocs.io.FeaturesProvides Django authentication backend to do Microsoft authentication
(including Microsoft accounts, Office 365 accounts and Azure AD accounts)
and Xbox Live authentication.Provides Microsoft OAuth client to interfacing with Microsoft accountsPython/Django supportdjango_microsoft_authfollows the samesupport cycle as Django.Supported python versions: 3.8+Supported Django version: 3.2+https://docs.djangoproject.com/en/stable/faq/install/#what-python-version-can-i-use-with-djangoCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.
Package: django-microsoft-auth-sync
Django microsoft authenticationIt is a very simple app which uses Microsoft authentication for user login and
admin panel login. It uses the Microsoft authentication library for Python (msal).InstallationStandard pip install:pipinstalldjango-microsoft-authenticationConfigurationFirst create an App inhttps://portal.azure.com/#home. There one needs to create set up for authentication. The details can be found here:https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-protect-backend-with-aadhttps://docs.microsoft.com/en-us/azure/app-service/configure-authentication-provider-microsoftAdd the following microsoft app authentication configuration to settings.py file. (e.g. below, please replace redirect and logout_uri with correct domain)MICROSOFT={"app_id":"YOUR_APP_ID_HERE","app_secret":"YOUR_APP_SECRET_HERE","redirect":"http://localhost:8000/microsoft_authentication/callback","scopes":["user.read"],"authority":"https://login.microsoftonline.com/common",# or using tenant "https://login.microsoftonline.com/{tenant}","valid_email_domains":["<list_of_valid_domains>"],"logout_uri":"http://localhost:8000/admin/logout"}Add the following line to settings.py to change the LOGIN_URL and LOGIN_REDIRECT_URL settings.LOGIN_URL="/microsoft_authentication/login"LOGIN_REDIRECT_URL="/admin"# optional and can be changed to any other urlAdd 'microsoft_authentication' to INSTALLED_APPSAdd the following to the project/urls.pyfromdjango.contribimportadminfromdjango.urlsimportpath,includeurlpatterns=[path('admin/',admin.site.urls),# Add the following linepath('microsoft_authentication/',include('microsoft_authentication.urls'))]How it works?It authenticates the user using their microsoft email and microsoft authentication.It also verifies if the domain of the microsoft authenticated email is also in MICROSOFT["valid_email_domains"]After the first two steps of authentication, if the user is not found, it creates a new user but with no access to any apps in admin panel.Superusers can assign User Groups to the users for Group based access to views.QuickstartThis app provides a decorator which can be used as follows:fromdjango.httpimportHttpResponsefrommicrosoft_authentication.auth.auth_decoratorsimportmicrosoft_login_required@microsoft_login_required()defhome(request):returnHttpResponse("Logged in")# If pages need to be restricted to certain groups of users.@microsoft_login_required(groups=("SpecificGroup1","SpecificGroup2"))# Add here the list of Group namesdefspecific_group_access(request):returnHttpResponse("You are accessing page which is accessible only to users belonging to SpecificGroup1 or SpecificGroup2")Troubleshooting during developmentUsehttp://localhost:8000instead ofhttp://127.0.0.1:8000because session cookies
are set differently for these urls.
Package: django-microsoft-sso
Easily integrate Microsoft Authentication into your Django projectsWelcome to Django Microsoft SSOThis library aims to simplify the process of authenticating users with Microsoft in Django Admin pages,
inspired by libraries likedjango_microsoft_authanddjango-admin-ssoDocumentationDocs:https://megalus.github.io/django-microsoft-sso/Install$pipinstalldjango-microsoft-ssoConfigureAdd the following to yoursettings.pyINSTALLED_APPS:# settings.pyINSTALLED_APPS=[# other django apps"django.contrib.messages",# Need for Auth messages"django_microsoft_sso",# Add django_microsoft_sso]InMicrosoft Entra Administration CenteratApplication Register, retrieve your
Application ID. Navigate toCertificate & secretslink, and get theClient Secret Value. Add both in yoursettings.py:# settings.pyMICROSOFT_SSO_APPLICATION_ID="your Application ID here"MICROSOFT_SSO_CLIENT_SECRET="your Client Secret Value here"Add the callback urihttp://localhost:8000/microsoft_sso/callback/in your Microsoft Console, on the "Authorized Redirect
URL".Let Django Microsoft SSO auto create users for allowable domains:# settings.pyMICROSOFT_SSO_ALLOWABLE_DOMAINS=["contoso.com"]Inurls.pyplease add theDjango-Microsoft-SSOviews:# urls.pyfromdjango.urlsimportinclude,pathurlpatterns=[# other urlpatterns...path("microsoft_sso/",include("django_microsoft_sso.urls",namespace="django_microsoft_sso")),]And run migrations:$pythonmanage.pymigrateThat's it. Start django on port 8000 and open your browser inhttp://localhost:8000/admin/loginand you should see the
Microsoft SSO button.LicenseThis project is licensed under the terms of the MIT license.
Package: django-middlewall
Simple middleware for blocking requests by IP AddressQuickstartInstall Django Middlewall:pip install django-middlewallAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'middlewall.apps.MiddlewallConfig',...)Enable middleware components:# enable both white and black listingMIDDLEWARE=['middlewall.middleware.BlacklistMiddleware','middlewall.middleware.WhitelistMiddleware',...]Define access lists in CIDR notation:# only allow requests from these subnetsMIDDLEWALL_WHITELIST=['192.0.2.0/24','198.51.100.0/24']# also block this specific addressMIDDLEWALL_BLACKLIST=['192.0.2.1/32'](optional) Define a custom function to get remote addresses from request
objects:# take advantage of the X_FORWARDED_FOR support in ipwareMIDDLEWALL_ADDRESS_GETTER='ipware.ip.get_ip'Running Testssource <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -e .[test]
(myenv) $ pip install tox
(myenv) $ toxCreditsCookiecuttercookiecutter-djangopackageipwareHistory0.1.2 (2017-03-09)General code clean up.0.1.1 (2017-03-09)First release.
Package: django-middleware-public-pages
==============================django-middleware-public-pages==============================Use this App to redirect the requests to 'public' alternative of the same view if the user is not logged in.For example, if there are two views registered:- page_private (name=page1)- page_public (name=page1_pub)If the user is not authenticated, the middleMiddleware will look for a url-name with the same name and the suffix '_pub' and redirect the request.If the user is authenticated or the 'public' URL is not found, the Middleware has no effect.Quick start-----------1. Install the app:1. Add it to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'django-middleware-public-pages',]2. Add the middleware at the end of the list in settings::MIDDLEWARE_CLASSES = (..."django-middleware-public-pages",)3. Configure two views, one for authenticated user e.g. page_private and anotherfor anonymous or public (page_public)::urlpatterns += [url("^page_private/$", views.Page1View.as_view(), name="page1"),url("^page_public/$",  views.Page2View.as_view(), name="page1_pub"),...]The middleware will automaticaly redirect "/page_private" to "/page_public" if the user is notauthenticated.Attention: important is the name of the view and not the url-path.Project page - https://gitlab.com/rristow/django-middleware-public-pages.git
Package: django-migrate-or-rollback
django-migrate-or-rollbackWhile single migrations in Django are atomic (as long as they have the defaultatomic=True),
a group of migrations are not.  Thus, when running migrations, you can have a partial
failure where some but not all of your migrations succeed.  This library fixes that.This library provides a new management commandmigrate_or_rollback.  It's a drop-in
replacement for the Django builtin management commandmigrate.  Here's how it works:Checks your database and current migration files for the latest migrations run per Django app.Runs migrations as normal.If migrations fail, it rolls back to the migrations identified in step 1.Instalationpip install django-migrate-or-rollbackAlternatively, adddjango-migrate-or-rollbackto your requirements.txt file.Then, add"django_migrate_or_rollback"to yourINSTALLED_APPSin settings.py, like so:# settings.py
INSTALLED_APPS = [
    # ...
    "django_migrate_or_rollback",
]UsageRunpython manage.py migrate_or_rollbackinstead of the standardmigratecommand.In particular, you should usemigrate_or_rollbackin place ofmigratein your deployment scripts or CI/CD system.migrate_or_rollbackhas all of the same options asmigrate, such as the--noinputflag.WarningThis library assumes that your migrations are reversable.  Not all migrations are reversible.  Additionally, rolling back migrations only reverses schema doesn't rewind the database contents.In particular:Deleted data (such as dropping columns or tables) won't be restored by rolling
back the migration that deletes it.  To avoid this, you should make fields
nullable in one deploy and delete them in the next.RunPythonstatements that are missing areversefunction will error on
rollback.  At a minimum, addmigrations.RunPython.noopas a reverse function.
Additionally, RunPython reverse functions can be used to rewind changes to
database contents on migration rollback.A migration that deletes a non-nullable field will error on rollback.
To avoid this, make the field nullable in one deploy and delete it in the next.
Package: django-migrate-with-schema-override
About-----I need some cursor override to prevent migrate from tripping on models with schema definition on 'db_table' such as those used with herokuconnect's salesforce schema.Installation------------The library is hosted on`PyPi <https://pypi.python.org/pypi/django-migrate-with-schema-override/>`_, so you cangrab it there with::pip install django-migrate-with-schema-overrideThen add ``cursor_override`` to your ``INSTALLED_APPS``.::INSTALLED_APPS = (# ...'cursor_override',# ...)Usage-----You need to add this line to your ``settings.py`` to enable the override:::# Set to False to allow writesCURSOR_OVERRIDE = TrueCredits-----Credit goes to 'http://github.com/streeter/django-db-readonly' where I've patterned the repository for I could not find any tutorials on how to override django's utils.pyThanks to you Chris Streeter!License-------Uses the `MIT <http://opensource.org/licenses/MIT>`_ license.
Package: django-migration-checker
Note: this project is not actively maintained. It’s also kind of an ugly hack, and most probably there are better ways to solve the same problem these days.The package allows to detect migration conflicts inDjangoapplication via static code analysis. In other words, it doesn’t run or import any of your code, but finds and parses Django migration files.The package should work fine with Python 3.6+, and migrations generated by Django 1.7 and later.Example:>>> from django_migration_checker import get_conflicts
>>> get_conflicts(app_dir='./django-project/apps')
[('accounts', ['0001_initial', '0002_new_migration'])]Free software: MIT licenseInstallationpip install django-migration-checkerWhy?The initial goal was to have some way to quickly analyze pull requests to a Django project and detect if the new changes introduce migration conflicts if they are merged tomaster.Here are a few features:FastNo database connections, heavy modules loading, or checks are performed, so why would it be slow?No up-to-date environment neededYou don’t need to have a working Django environment (validsettings.pyfile, all installed dependencies, etc.) to use this package. The only requirement is to have properly generated migration files.No dependenciesThe package doesn’t require Django itself, NumPy, left-pad, or any other packages.Command-line toolAfter installing the package you can use the command-line scriptdjango-find-conflictsto detect migration conflicts from your console.Here’s how it looks like:$ django-find-conflicts ./django-project/apps
[('accounts', ['0001_initial', '0002_new_migration'])]

$ django-find-conflicts ./another-django-project/apps
No conflicts detected.CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.# Changelog## [0.8.0] - 2023-01-05Support multiple projects when in CLI mode ([#12](https://github.com/tonyo/django-migration-checker/pull/12))## [0.7.1] - 2022-07-31Fix error on double quote and multiple dependencies ([#11](https://github.com/tonyo/django-migration-checker/pull/11))## [0.7.0] - 2021-12-26Accept both single and double quotes ([#9](https://github.com/tonyo/django-migration-checker/pull/9))Drop support for Python 2.7 and 3.5Move to GitHub ActionsGet rid of Travis## [0.6.0] - 2020-12-05Exit with code 1 when conflicts are found ([#7](https://github.com/tonyo/django-migration-checker/pull/7))## [0.1.0] - 2016-09-09First release on PyPI.
Package: django-migration-dependencies
Django Migration Dependency GraphThis is an app that helps developers understand how their migrations are interconnected across their apps, serving as a tool to identify possible circular dependencies when squashing them.Installationpip install django-migration-dependenciesQuick startAdd "migrations-graph" to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
...
'migrations-graph',
]Include the polls URLconf in your project urls.py like this::import migrations_graph.urls
path('migrations-graph/', include('migrations_graph.urls')),Start the development server.Visithttp://127.0.0.1:8000/migrations_graph/to see the graph.CaveatsSome times you won't get a graph for some reason and find an error in the browser's consoleCannot set property 'order' of undefined.... Change the layout by passing the query param?layout=breadthfirst. For more info seehttps://github.com/dagrejs/dagre/issues/234DisclaimerThis is a real quick hack to help a one-time need (for now). You won't find tests here (...that is, for now).
Package: django-migration-docs
django-migration-docsMigrations can be one of the most challenging aspects of deploying a Django application at scale. Depending on the size of tables and flavor of database, some migrations can easily lock some of the most important tables and bring down an application if more scrutiny isn't applied towards deployed migrations. Along with this, sometimes we must document more critical metadata about a migration before it is even deployed, such as when the migration should run in the deployment process.django-migration-docsprovides the ability to collect more structured information about every migration in your Django project. Along with this, it also automatically collects important metadata about migrations like the raw SQL so that more information is available for reviewers and maintainers of a large project.Whendjango-migration-docsis installed, users will be prompted for more information about migrations using a completely customizable schema that can be linted in continuous integration. The default prompt looks like the following:Check out thedocsfor more information about how to usedjango-migration-docsin your application.Compatibilitydjango-migration-docsis compatible with Python 3.8 - 3.12 and Django 3.2 - 5.0..DocumentationView the django-migration-docs docs hereInstallationInstalldjango-migration-docswith:pip3 install django-migration-docsAfter this, addmigration_docsto theINSTALLED_APPSsetting of your Django project.Contributing GuideFor information on setting up django-migration-docs for development and contributing changes, viewCONTRIBUTING.md.Primary Authors@juemura (Juliana de Heer)@wesleykendall (Wes Kendall)@tomage (Tómas Árni Jónasson)