Saravanan666/pypi-org huggingface dataset:
Package: django-allbasic
All BasicAll Basic is a simple Django app to to add some basic functionality to use the DRF API. It consists of separating business logic and the application of nested data that comes from user requests and validations that support nested data.Quick startAddallbasicto yourINSTALLED_APPSsetting like this:INSTALLED_APPS = [
    ...
    'allbasic',
]Create an application (what name is up) and create several files:myapp/
    domains.py
    presentations.py
    validations.pyIn yourvalidations.py:from allbasic.validations import BaseValidation

class ValidationUserDetailUpdate(BaseValidation):
    def schema(self):
        return {
            'last_name': {
                'type': 'string',
                'required': True,
                'empty': False
            },
            'first_name': {
                'type': 'string',
                'required': True,
                'empty': False
            }
        }In yourdomains.py:from allbasic.domains import BaseDomain

class DomainUserUpdate(BaseDomain):
    @transaction.atomic()
    def apply(self):
        data = self.context.get('data')
        user = self.context.get('user')

        user.first_name = data.get('first_name', user.first_name)
        user.last_name = data.get('last_name', user.last_name)

        return user.save()In yourpresentations.py:from allbasic.presentations import BasePresentation

class UserDetailPresentation(BasePresentation):
    def present(self):
        user = self.context.get('user')

        return {
            'id': user.pk,
            'username': user.username,
            'email': user.email,
            'last_name': user.last_name,
            'first_name': user.first_name
        }In yourviews.py:from allbasic.domains import ContextDomain
from allbasic.presentations import ContextPresentation
from allbasic.validations import ContextValidation

class UserDetailView(APIView):
    authentication_classes = (
        JSONWebTokenAuthentication,
        SessionAuthentication,
        BasicAuthentication
    )
    permission_classes = (IsAuthenticated,)

    def put(self, request):
        validation = ContextValidation(ValidationUserDetailUpdate(request.data))

        if validation.validate():
            ContextDomain(DomainUserUpdate(context={'data': validation.data, 'user': request.user})).do_apply()
            presentation = ContextPresentation(UserDetailPresentation(context={'user': request.user}))
            return Response(presentation.do_present())

        return Response(validation.errors, status=status.HTTP_400_BAD_REQUEST)
Package: django-allbymyself
All By Myself - Django SingletonsSingletons are objects that can only be instantiated once and serve a specific purpose. A classic example of where a singleton is necessary in web development is site configuration.
This package provides an abstract singleton base model,SingletonBaseModel, along with a model admin,SingletonBaseModelAdmin, both of which are utilized to create and manage singleton objects in Django.Installation$pipinstalldjango-allbymyselfQuick StartAdd toINSTALLED_APPSin your project'ssettings.pyto load custom admin templates:INSTALLED_APPS=[...'allbymyself',]Create a model inyour_app/models.pyand subclassSingletonBaseModel:fromdjango.dbimportmodelsfromallbymyself.modelsimportSingletonBaseModelclassSiteSettings(SingletonBaseModel):site_title=models.CharField(max_length=50)about=models.CharField(max_length=255)Register the model inyour_app/admin.py, subclassingSingletonBaseModelAdmin:fromdjango.contribimportadminfromallbymyself.adminimportSingletonBaseModelAdminfromyour_app.modelsimportSiteSettings@admin.register(SiteSettings)classSiteSettingsAdmin(SingletonBaseModelAdmin):fields=('site_title','about')FeaturesSkips change list page and instead goes straight to the change form or add form.SingletonBaseModelhandles caching and uncaching.Admin URLs for change form and history form will not include object id.After saving changes or adding a new instance, the admin user is redirected to the admin index.Overrideis_default_availableand returnTrueto create an instance on admin page startup:classSiteSettings(SingletonBaseModel):site_title=models.CharField(max_length=50,blank=True)about=models.CharField(max_length=255,blank=True)@classmethoddefis_default_available(cls):# if True, make sure to handle field defaults in your model# appropriately!returnTrueContext ProcessorYou may also add your object as a context processor to make it available in all templates, site-wide. First createyour_app/context_processors.pyand add the following:fromdjango.urlsimportreversefromyour_app.modelsimportSiteSettingsdefsite_settings(request):ifrequest.path.startswith(reverse('admin:index')):return{}else:return{'site_settings':SiteSettings.get()}The aboveifstatement prevents creation of an instance on admin page startup. This is only necessary ifis_default_availablereturnsFalse. Then, in your project'ssettings.py:TEMPLATES=[{...'OPTIONS':{'context_processors':[...'your_app.context_processors.site_settings',],},},]You can then access your object in your templates like any other piece of context:<h1>{{ site_settings.site_title }}</h1><p>{{ site_settings.about }}</p>TestingSimply run tests like so:$pythonmanage.pytestallbymyself
Package: django-allow-cidr
A Django Middleware to enable use of CIDR IP ranges in ALLOWED_HOSTS.QuickstartInstall Django Allow CIDR:pip install django-allow-cidrAdd the Middleware to yourMIDDLEWAREsettings. It should be the first in the list:MIDDLEWARE=('allow_cidr.middleware.AllowCIDRMiddleware',...)Add theALLOWED_CIDR_NETSsetting:ALLOWED_CIDR_NETS=['192.168.1.0/24']Profit!FeaturesThe normalALLOWED_HOSTSvalues will also work as intended. This Middleware is intended to augment,
not replace, the normal Django function.If you do defineALLOWED_CIDR_NETSand it has values, the middleware will capture what you have inALLOWED_HOSTS,
setALLOWED_HOSTSto[‘*’]and take over validation of host headers.TheALLOWED_CIDR_NETSvalues can be any valid network definition for thenetaddrpackage.Running TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxPushing to PyPICutting a new Github Release will trigger CI checks, followed by an automatic release to PyPI, using the release version.
Please make sure that your Github Release version matches the project version in__init__.py.For more details see thereleasejob in.github/workflows/ci.yml.CreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.7.1 (2023-07-10)Update setup.cfg to rename deprecated licence_file param0.7.0 (2023-07-10)Add IPv6 support - thanks @rissson!Add Django 4.2 to CI; freshen up CI config0.6.0 (2023-01-05)Drop dev-related dependencies (incl vulnerable version of wheel, which was not installed in general use)Remove redundant code from setup.py now we’re auto-publishing via GithubUpdate testing matrix: Drop Python 3.6; add Python 3.11; add Django 4.10.5.0 (2022-07-09)Replace the netaddr dependency with Python 3’s ipaddress - thanks @n1ngu!Update GH actions to release to PyPI0.4.1 (2022-06-13)Use packaging.version to avoid distutils deprecated module - thanks @adamantike!0.4.0 (2022-02-22)Drop Django support for non-LTS and non-latest Django (so, removing 1.x, 2.0, 2.1, 3.0, 3.1)Drop support for older Python releases (2.x, 3.5)Add Django 4.0 to tox’s test matrixAdd Python 3.7 through 3.10 to tox’s test matrix; 3.6 to 3.10 are now the only tested versionsSwitch CI to Github Actions0.3.1 (2018-07-31)Fix issue #6: Accept passed inget_responsefunction for Middleware in Django >= 1.10.Publish updated docs that fix theALLOWED_CIDR_NETStypo.0.3.0 (2018-02-21)Disable middleware if ALLOWED_HOSTS is set to[‘*’].0.2.0 (2018-02-21)Handle host names with ports (Thanks Giorgos!).0.1.0 (2018-02-16)First release on PyPI.
Package: django-allowedsites
Django 1.6+ library for setting yourALLOWED_HOSTSbased on the domains indjango.contrib.sitesUsage is something like the following, in yoursettings.pyor equivalent:from allowedsites import AllowedSites
ALLOWED_HOSTS = AllowedSites(defaults=('mytestsite.com',))Or, if you want to use your cache backend:from allowedsites import CachedAllowedSites
ALLOWED_HOSTS = CachedAllowedSites()A single key,allowedsiteswill be inserted containing an unsorted collection
of all the domains that are in thedjango.contrib.sites. For the sake of allowing
multiple processes to keep up to date with theSitevalues without hitting
the database, using a shared cache (ie: notLocMemCache) is encouraged.TheCachedAllowedSitesalso provides anupdate_cacheclass method which
may be used as a signal listener:from django.db.models.signals import post_save
from django.contrib.sites.models import Site
post_save.connect(CachedAllowedSites.update_cache, sender=Site,
                  dispatch_uid='update_allowedsites')You can modify the the defaults:from allowedsites import AllowedSites
ALLOWED_HOSTS = AllowedSites(defaults=('mytestsite.com',))
ALLOWED_HOSTS += AllowedSites(defaults=('anothersite.net',))
ALLOWED_HOSTS -= AllowedSites(defaults=('mytestsite.com',))
# ultimately, only anothersite.net is in the defaultsOther uses?Itmaywork withdjango-csp(Content Security Policy headers),django-dcors(Cross-Origin Resource Sharing headers) and others. I don’t know.Copyright (c) 2014, Keryn Knight
All rights reserved.Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.This license applies to version 0.1.0 of django-allowedsites.
Package: django-allow-healthchecks
Django Allow Health-ChecksBackgroundKubernetes, load-balancers and other PaaS have a concept of a health check. These are simple GET requests against an endpoint that you define which tells the orchestrator if a web worker is healthy or not. The problem is that these requests come from within the same network running your app using an non-deterministic hostname or IP address. So instead of making your allowed hosts wide open with['*'](to allow any requests to get by), you can simply install this package to allow these requests to occur without introducing more technical/security risks then necessary.For example, given a kubernetes deployment with the following details:#... other detailscontainers:-name:appimage:registry.gitlab.com/username/cool-app/applivenessProbe:httpGet:path:/health-check/port:8000httpHeaders:-name:X-Healthvalue:XYZ-123initialDelaySeconds:3periodSeconds:60imagePullPolicy:AlwaysYou can allow these requests to get by by simply adding this to your settingsHEALTH_CHECK_HEADER_VALUE = 'XYZ-123'SetupInstall django-allow-healthcheckspip3 install django-allow-healthchecksAdd the class to your middleware, ideally first in the listMIDDLEWARE=['django_allow_healthchecks.middleware.ByPassForHealthChecks',# <~ Add this'django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]Assign your magical header valueHEALTH_CHECK_HEADER_VALUE = 'XYZ-Health'NotesPython3.5+ + Django 2.2+! Get on board!!
Package: django-almastorage
almastorage========Simple web-application used for accessing project with SwiftStack storageQuick Install-------------1) Install almastorage:pip install django-almastorage2) Add 'almastorage' into your INSTALLED_APPS in project settings3) Add fields into project settings infortation from your swiftstack:SW_USERNAME = 'user'//account nameSW_KEY = 'key' //account keySW_AUTH_URL = 'http://your_url' //auth_urlAUTH_USER_MODEL = 'your User model' //your User model4) Migrate./manage.py migrate almastorage5) Create default container./manage.py shell> from almastorage.models import SwiftContainer> SwiftContainer.create_default_container()-------------You can download it directly from storage, but in that case your filename will be some key generatedfrom your filename and uploaded date. For download you can use 'download' view from views.py, justappend to your urls url(r'^files', include('almastorage.urls')), and then download using swiftfile id, 'http://your_domain/files/download/(?P<file_id>[0-9]+)/'-------------Use API for upload: http://yourdomain/api/v1/storage/:SW_USERNAME/upload/post_data={'filename': filename,'content_type': mime_type,'uploaded_file': base64.b64encode(open(file_path, "rb").read())}Use API for download: http://yourdomain/api/v1/file/:id/download/which will return {'temp_url': 'http://temp_url'}, use get to this url to get the file
Package: django-aloha
What is django-alohadjango-aloha is a django app to easily integrate editing with Aloha
WYSIWIG editor in django apps.You just edit the blocks of text on your pages, no admin needed.How it worksdjango-aloha wraps editable text fields into separate forms. See how
to do it in the “Usage” section.Installationdownload aloha-editor from GitHubhttps://github.com/alohaeditor/Aloha-Editormy version was commit 787859e2313337f171f32b7574cec23393fa6a77For existing JS and CSS to work (this is optional, you can create your own ones)
place the aloha files into your {{MEDIA_URL}}js/aloha/, so that the
“lib” directory is in {{MEDIA_URL}}js/aloha/lib/.Install django-aloha into your python:easy_install django-alohaAdd “django-aloha” to INSTALLED_APPS in settings.pyMake sure you have jquery enabled.(Optional) add existing JS and CSS to your templates, where you usually place JS and CSS:{% include 'aloha/includes/js.html' %}
{% include 'aloha/includes/css.html' %}Or you can just copy these files into your TEMPLATES dir, and edit
according to your needs.UsageUse in your templates like this.Option one - you want to edit a certain field on a model instance:{% load aloha_tags %}

{% aloha my_object_from_the_database 'fieldname_where_text_is' [url_to_save] %}
   {{ my_object_from_the_database.fieldname_where_text_is|safe }}
{% endaloha %}If you want, you can add an optional “url” parameter to do custom
POST processing. If not provided, aloha.views.save will be used.Option two - you want to edit arbitrary text, and optionally, provide and url to save it:{% load aloha_tags %}

{% aloha [url_to_save_to] %}
   <p>Place here what you want to edit</p>
{% endaloha %}The custom save URL should process POST requests, and accepts following parameters:object_namefield_nameobject_pkcontentAll of these are generated by the tag, no need to worry about them.TODOAdd more strict permission processing (not it just uses
request.user.is_staff to check for permissions)Process thourgh AJAX instead of raw POSTS (to protect data loss on
errors)
Package: django-aloha-editor
The Django Aloha Editor is a WYSIWYG editor for all your Django powered websites
By default it always uses the latest version of Aloha Editorhttp://aloha-editor.org/How it worksDjango Aloha Editor checks the user permissons, wraps the content with an aloha editor <div> and
saves the edited content with an AJAX call.Installationpip install django-aloha-editorAdd the following url to your project’surls.pyfile:url(r'^__alohaeditor__/',include('aloha_editor.urls',namespace='aloha_editor')),Addaloha_editorto yourINSTALLED_APPSsetting so Django can find the
template files and template tags associated with Aloha Editor.Exampleviews.pyfromdjango.shortcutsimportrender_to_responsefrombooks.modelsimportBookdefbook_detail(request,book_id):try:book=Book.objects.get(pk=book_id)exceptBook.DoesNotExist:raiseHttp404returnrender_to_response('book_detail.html',{'book':book})book_detail.html{% load aloha_editor %}<html><head>{% if user.is_authenticated %}
    {% include "aloha_editor/css.html" %}
    {% include "aloha_editor/js.html" %}
  {% endif %}</head><body><h1>{{ book.title }}</h1>{% aloha_editor book.description %}</body></html>TODOs and BUGSYou found a bug or have a suggestion for improvement, please let me know!See:http://github.com/baskoopmans/django-aloha-editor/issues
Package: django-alttext
Generic alt text model associated to files by their path.InstallInstall via pip:pip installdjango-alttext.Addalttextto yourINSTALLED_APPS.Run migrations.Optionally follow the integration instructions that apply to your case.UsageUsing one of the supported integrations staff users will be able to add alt text for images in the admin interface. The app stores a list of alt texts by their associated image path.In your templates, you can now access the alt text for any file using thealttextfilter:{% load alttext_tags %}
<img src="{{ mymodel.imagefield }}" alt="{{ mymodel.imagefield|alttext }}" >Mezzanine integrationIf you’re using Mezzanine and filebrowser-safe, addalttext.mezzanineto your INSTALLED_APPS beforemezzanine.bootto enable alt-text links in the admin. A link to “Edit alt text” will appear next to eachFileFieldin Add and Change forms.ConfigurationEnable the admin list view to manage all AltText instances:settings.ALTTEXT_ADMIN_DISPLAY = True.ContributingReview contribution guidelines atCONTRIBUTING.md.
Package: django-altuser
INSTALLPut altuser in INSTALLED_APPSINSTALLED_APPS += (
    'altuser',
    )and configure your preferred user model from available altuser/models.py,
for exampleAUTH_USER_MODEL = 'altuser.MailSocialUser'Available modelsMailUserMailSocialUserMailConfirmedUserMailConfirmedSocialUserMailSocialConfirmfollowUserMailConfirmedSocialConfirmfollowUserUSAGEOneToOneIf you use this User model with another Profile model you
should put this field on you Profile modeluser = models.OneToOneField(settings.AUTH_USER_MODEL,
                           related_name='profile')If you have multiple profile types, you should use User.get_profile() to get
the right profile associated with this user, but you also must setALTUSER_PROFILES_BREL = ['profile']to a list of backward relation names (relate_name), of various profiles you have.
For example if you have two models, client and managers, associated with a OneToOneField to
our user model, and they have different related_name, one client_profile and the other
manager_profile, then ALTUSER_PROFILES_BREL must be [‘client_profile’, ‘manager_profile’]GenericRelationActually you can also use the internal profile_type generic relation
on the provided AbstractMailUser, that will permit you to coerce one
profile type per user, it is up to you if using that or not.# used in this way: self.user.get().usermodelfield
user = generic.GenericRelation(settings.AUTH_USER_MODEL,
content_type_field='profile_type',
object_id_field='profile_id')Generic relations in this way permits to have your user and profile
in the same inline and for example in the admin:from django.contrib import admin
from .models import MannequineProfile
from django.contrib.auth import get_user_model
from django.contrib.contenttypes import generic

class UserInline(generic.GenericTabularInline):
    model=get_user_model()
    extra=1
    max_num=1
ct_field = 'profile_type'
ct_fk_field = 'profile_id'
exclude = ('last_login', 'is_staff', 'is_superuser',
        'groups', 'user_permissions' ,'likes',
        'follows')


class ProfileAdmin(admin.ModelAdmin):
    inlines = [
    UserInline,
    ]


admin.site.register(Profile, ProfileAdmin)Note also, that if you delete an object that has a GenericRelation, any objects which have a GenericForeignKey pointing at it will be deleted as well.
In the example above, this means that if a Profile object were deleted, any user objects pointing at it would be deleted at the same time.Confirmed Modelsfor using the mail confirmed models you must use [django-mail_confirmation](http://v.licheni.net/drc/django-mail_confirmation.git)to filter out users that has confirmed social relations you do something like this:get_user_model().objects.filter(id=user.id, follows=otheruser, relations__confirmed__confirmed=True)
Package: django-always-authenticated
A middleware that ensures that a request always has an authenticated user.If the request doesn’t have an authenticated user, it logs in a default
user. If the default user doesn’t exist, it is created.CompatibilityThis middleware has been tested with these versions of Django:1.71.81.91.10master (at the time of the release)SetupInstall from PyPI:pip install django_always_authenticatedAdd toMIDDLEWARE(MIDDLEWARE_CLASSESfor Django <1.10) in settings file:MIDDLEWARE = (
    ...
    'always_authenticated.middleware.AlwaysAuthenticatedMiddleware',
)As a security safeguard, the middleware will raise anImproperlyConfiguredExceptionwhen running in production mode
(DEBUG=False).
To run the middleware in production, setALWAYS_AUTHENTICATED_DEBUG_ONLYtoFalse.ConfigurationThis middleware reads these settings:ALWAYS_AUTHENTICATED_USERNAMEA string with the name of the default user, defaults to'user'.ALWAYS_AUTHENTICATED_USER_DEFAULTSA dict with additional default values to set when creating the user.ALWAYS_AUTHENTICATED_DEBUG_ONLYSet toFalseto allow running with DEBUG=False.Example projectThere is a very single example project that demonstrates the middleware in the
directoryexample_project.Running TestsTo run the tests, install the requirements and run py.test:pip install -r requirements.txt
py.testYou can also use tox to run the tests with all supported versions of
Python and Django:pip install tox
tox
Package: django-amazon-sns-mobile-push-notification
Django SNS Mobile Push NotificationsSend mobile push notification to IOS and android devices using Amazon SNS.Documentationhttps://django-sns-mobile-push-notification.readthedocs.io/Project Homehttps://github.com/fuzz-productions/django-sns-mobile-push-notificationPyPihttps://pypi.python.org/pypi/django-sns-mobile-push-notification
Package: django-amazon-translate
Django Amazon TranslateUtilities for Django to translate both Models and Django gettext files using
Amazon Translate.Written because doing translation ends up getting forgotten and increasing
accessibility in projects should be easy for everyone.Free software: MIT licenseDocumentation:https://django-amazon-translate.readthedocs.io.Quick startAdddjango_amazon_translateto the INSTALLED_APPS of your project.FeaturesTranslate via a management command to update po files with translated text.Translate via Django model translate where if a string is saved and has not
been edited, it will go ahead and translate on save.CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0First release on PyPI.