Saravanan666/pypi-org huggingface dataset:
Package: dj-oauth-clients
Django app for handling oauth2 clients.DocumentationThe full documentation is athttps://dj-oauth-clients.readthedocs.io.QuickstartInstall Django Oauth2 Clients:pip install dj-oauth-clientsAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'oauth_clients.apps.OauthClientsConfig',...)Add Django Oauth2 Clients’s URL patterns:fromoauth_clientsimporturlsasoauth_clients_urlsurlpatterns=[...url(r'^',include(oauth_clients_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 (2018-11-21)First release on PyPI.
Package: dj-obj-update
Django Object Updatedj-obj-updateis a module that helps you do two things while updating
an object:Only do a save if something changedLog what changed (the logger name isobj_updateand only outputslogging.DEBUG)Installationpip install dj-obj-updateUsageUpdating an objectfrom obj_update import obj_update

new_data = {
    'flavor': 'chocolate',
}
for obj in queryset:
    obj_update(obj, new_data)Dry run updating an objectfrom obj_update import obj_update

logger.setLevel(logging.DEBUG)  # see "Logging changes" below

new_data = {
    'flavor': 'chocolate',
}
for obj in queryset:
    obj_update(obj, new_data, update_fields=[])Replacement forupdate_or_createfrom obj_update import obj_update_or_create

choice, created = obj_update_or_create(
    Choice,
    question=question,
    defaults={'choice_text': 'Flour or corn?'},
)Dealing withauto_nowfieldsBy default,dj-obj-updateconstructs anupdate_fieldswhen it saves.
This means fields like the primary key,auto_now, andauto_now_addmight not get saved. If you need these, you should setupdate_fields=None. Usage is the same as Django'supdate_fieldsLogging changesUsingpython-json-logger:import logging
from pythonjsonlogger.jsonlogger import JsonFormatter

logger = logging.getLogger('obj_update')
handler = logging.FileHandler('log/my_obj_changes.log')
handler.setFormatter(JsonFormatter())
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)With JSON logging, you'll get messages like:{"message": "[text hello->hello2]", "model": "FooModel", "pk": 1, "changes": {"text": {"old": "hello", "new": "hello2"}}}With a normal logger, you'll still get output, but it won't have as much
information:[text hello->hello2]You can selectively log object creation or updates. For example, if you don't
expect objects to be created, you can only enable theobj_update.createlogger. Likewise, you can only enable theobj_update.updatelogger to ignore
creation. See thelogging.configexample at the top oftest_obj_updatefor an example.
Package: djohno
djohno is a tiny app for checking over your error pages, and email
integration - to stop me doing evil things post-production to ensure
I’ve set up Sentry and my error pages by randomly breaking parts of my
site by editing code live.Documentation is available athttps://djohno.readthedocs.org.Tests are run on Travis with every push - seehttps://travis-ci.org/dominicrodger/djohno.Release notes are available athttps://djohno.readthedocs.org/en/latest/release_notes.html.Sneak PreviewWhen installed, djohno looks a little bit like this:
Package: djonet
Djonet is a MonetDB backend for Django.Installationrun from the source folder:$ python setup.py installor make sure the Djonet source directory is in yourPYTHONPATH.Djonet is also installable with pip:$ pip install djonetUsageput something like this in your Djangosettings.py:DATABASES = {
    'default': {
        'ENGINE': 'djonet',
        'NAME': 'database_name',
        'USER': 'database_user',
        'PASSWORD': 'database_password',
        'HOST': 'database_host',
        'PORT': '5000',
    }
}Abouthttp://www.monetdb.org/
Package: djongo
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo5
Use Mongodb as a backend database for your django project, without changing a
single django model! This version supports Django 5.UsageInstall djongo:pip install djongo5Into settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo-bn
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo-certego
This is a Fork from Certego S.R.L.Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo-cora
Note: This package has been created by forking original djongo repo to upgrade JQuery version from from 3.3.1 to 3.5.1
[Managed by CORA-AI-NLU]UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksSource code
Package: djongoForeign
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo-itday
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important links
Package: djongo-lndata
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongo-lndataInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo-mongo-version-fix
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djongo-optimistic-lock
Implements an offline optimistic lock[1]for Django models.UsageAdd aVersionFieldand inherit fromVersionedMixin.fromdolimportVersionField,VersionedMixinclassMyModel(VersionedMixin,models.Model):version=VersionField()WheneverMyModelis saved, the version will be checked to ensure
the instance has not changed since it was last fetched. If there is a
conflict, aConcurrentUpdateexception will be raised.ImplementationAVersionFieldis just an integer that increments itself every
time its model is saved.VersionedMixinoverrides_do_update(which is called bysaveto actually do the update) to add an extra
condition to the update query – that the version in the database is
the same as the model’s version. If they match, there have been no
concurrent modifications. If they don’t match, the UPDATE statement will
not update any rows, and we know that someone else saved first.This produces SQL that looks something like:UPDATE mymodel SET version = version + 1, ... WHERE id = %s AND version = %sWhen no rows were updated, we know someone else won and we need to raise
aConcurrentUpdate.Comparison todjango-concurrencydjango-concurrencybefore
version 0.7 usedSELECT FOR UPDATEto implement the version checking. I
wanted to avoid database-level locking, sodjango-optimistic-lockadds a
version filter to the update statement, as described by Martin Fowler[1].Additionally, ool takes a more minimalistic approach than
django-concurrency by only doing one thing – optimistic locking –
without any monkey-patching, middleware, settings variables, admin
classes, or form fields. django-concurrency would probably make more sense
if you’re looking for something that will attempt to accommodate every
situation out of the box. Use ool if you just want a straightforward model
implementation and need to handle the UI and surrounding architecture
yourself.Running the testsmake test[1](1,2)http://martinfowler.com/eaaCatalog/optimisticOfflineLock.html[2]https://code.djangoproject.com/ticket/16649
Package: djongox
Use Mongodb as a backend database for your django project, without changing a
single django model!UsageInstall djongo:pip install djongoxInto settings.py file of your project, add:DATABASES = {
     'default': {
         'ENGINE': 'djongo',
         'NAME': 'your-db-name',
     }
 }Run (ONLY the first time to create collections in mongoDB):manage.py makemigrations
manage.py migrateYOUR ARE SET! HAVE FUN!RequirementsDjongo requires python 3.6 or above.How it worksDjongo is a SQL to mongodb query transpiler. It translates a SQL query string
into a mongoDB query document. As a result, all Django features, models etc
work as is.Django contrib modules:'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',and others… fully supported.Important linksFull DocumentationSource code
Package: djoosh
Djoosh is a very simple search engine for your Django projects.WARNING: This is currently under heavy development, so use at your work risk!InstallationInstall with pip:pip install djooshAdddjooshtoINSTALLED_APPSin yoursettings.py:INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        ...
        'djoosh',
)In yourmodels.pyadd:from djoosh import SearchMixin

...

class BlogPost(models.Model, SearchMixin):
        ...NoteSearchMixinin the parents forMyModel. Just add it to any model
that you want to search.When you’re done, runpython manage.py search rebuildThat’s it! You can now search your blog posts usingBlogPost.search.query('somequery'),For example you can create a view like this:def search(request):

        query = request.GET.get('q', '')

        posts = BlogPost.search.query(query)

        return render_to_response('search_posts.html',
                                  {'posts': posts, 'query': query})… and your template can be:<form action="/search" method="get">
        <input type="text" name="q" value="{{ query }}" />
        <input type="submit" value="Search Blogs" />
</form>

<h1>Search Results</h1>
{% for post in posts %}
        <h2>{{ post.title }}</h2>
        <p>{{ post.content }}</p>
{% endfor %}Fine-TuningComing soon…For the impatient:blog/search.py:

from blog import BlogPost
from djoosh import site, SearchModel

class BlogPostSearch(SearchModel):
        model = BlogPost
        fields = ('title', 'tags')
        keywords = ('tags',)
        pk = 'id'

site.register(BlogPost, BlogPostSearch)You may also have a look atdjoosh.loading, particularlysiteandSearchModel.
Package: dj-optimizely
dj-optimizelyIntroductionDatabase-backed storage for your Optimizaly datafile and utilities for using Rollouts in Django.Features:Database-backed storage for Optimizaly datafileWebhook endpoint to recieve datafile updatesThe webhook payload contains the datafile for the primary environment. If the current environment is not the primary environment, the webhook call will trigger a fetch of your current environment's datafile. Only your current environment's datafile is stored locally at this time.On server start the datafile will be initialized via a pull based on the provided datafile urlCurrently only supports Rollouts. Check if a featuee flag is enabled.QuickstartInstall:pip install dj-optimizelyAdddjoptimizelytoINSTALLED_APPS:INSTALLED_APPS = [
    ...
    'djoptimizely',
    ...
]Adddjoptimizely.middleware.optimizely_middlewaretoMIDDLEWARE:MIDDLEWARE = [
    ...
    'djoptimizely.middleware.optimizely_middleware',
    ...
]Specify additional required settings:OPTIMIZELY_ENVIRONMENT = 'staging'
OPTIMIZELY_WEBHOOK_SECRET = os.getenv('OPTIMIZELY_WEBHOOK_SECRET')
OPTIMIZELY_DATAFILE_URL = os.getenv('OPTIMIZELY_DATAFILE_URL')Specify optional callbacks. Both functions take therequestas the first parameter:OPTIMIZELY_USER_ID_CALLBACK = 'myapp.module.get_user_id'
OPTIMIZELY_USER_ATTRIBS_CALLBACK = 'myapp.module.get_user_attribs'Default callbacks:def get_user_id_default(request):
    if request.user.is_authenticated:
        return request.user.pk
    else:
        return request.session._get_or_create_session_key()

def get_user_attribs_default(request):
    attribs = {
        'is_authenticated': False,
        'is_staff': False
    }
    if request.user.is_authenticated:
        attribs['is_authenticated'] = True
        if request.user.is_staff:
            attribs['is_staff'] = True

    return attribsAdd the webhook to urls.py:path('webhooks/', include('djoptimizely.urls')),Check if a feature should be enabled:from djoptimizely.services import get_feature_enabled

if get_feature_enabled(request, 'cool_stuff'):
    print('Cool!')Check in a template{% load djoptimizely_tags %}

{% feature_enabled 'cool_stuff' as show_cool_stuff %}
{% if show_cool_stuff %}
    <p>COOL Stuff!</p>
{% endif %}Generic view mixin:If the specifiedfeature_keyisnot enabledforrequest.userreturn a 404from djoptimizely.mixins import OptimizelyFeatureViewMixin
from django.views.generic.base import TemplateView

class CoolView(OptimizelyFeatureViewMixin, TemplateView):
    feature_key = 'cool_stuff'
    ...
Package: djorm-ext-core
This module contaisn all basic and generic improvements needed by all submodules.PostgreSQL server side cursorsFor most cases, the normal cursor and django psycopg2 are more than enough. But there are cases where we have to do queries to tables with large amounts of data, and we need an efficient way to query this data.On first step, putdjorm_core.postgresqlin yourINSTALLED_APPS.This is a simple example of usage:fromdjorm_core.postgresqlimportserver_side_cursorswithserver_side_cursors():foriteminModel.objects.all():printitem.value
Package: djorm-ext-expressions
Django by default, provides a wide range of field types and generic lookups for queries. This in many cases is more than enough. But there are cases where you need to use types defined for yourself and search operators that are not defined in django lookups and another important case is to make searches requiring the execution of some function in WHERE clause.In django, for these last two cases, it requires writing SQL statements.djorm-ext-expressionsintroduces the methodmanager.where()and some class’es (SqlExpression, SqlFunction, AND, OR, …) to facilite sql construction for advanced cases.Simple usageImagine some django model with postgresql integer array field. You need to find objects in the field containing a set of group numbers.NOTE: array field is part of django orm extensions package and is located ondjorm-ext-pgarraysubmodule.Example model definitionfromdjango.dbimportmodelsfromdjorm_expressions.modelsimportExpressionManagerfrom.somefielsimportArrayFieldclassRegister(models.Model):name=models.CharField(max_length=200)points=ArrayField(dbtype="int")objects=ExpressionManager()With this model definition, we can do this searches:fromdjorm_expressions.baseimportSqlExpression,AND,OR# search all register items that points field contains [2,3]qs=Register.manager.where(SqlExpression("points","@>",[2,3]))# search all register items that points fields contains [2,3] or [5,6]expression=OR(SqlExpression("points","@>",[2,3]),SqlExpression("points","@>",[5,6]),)qs=Register.objects.where(expression)Also, we can use functions to construct a expression:fromdjorm_expressions.baseimportSqlFunctionclassBitLength(SqlFunction):sql_function="bit_length"# search all registers items that bit_length(name) > 20.qs=Register.objects.where(SqlExpression(BitLength("name"),">",20))I finally can redefine the behavior “SqlExpression” and make it more “object oriented”:classArrayExpression(object):def__init__(self,field):self.field=fielddefcontains(self,value):returnSqlExpression(self.field,"@>",value)defoverlap(self,value):returnSqlExpression(self.field,"&&",value)# search all register items that points field contains [2,3]qs=Register.objects.where(ArrayExpression("points").contains([2,3]))
Package: djorm-ext-pgarray
PostgreSQL array field for Django.Blog post:http://www.niwi.be/2012/10/07/postgresql-array-fields-with-django/IntroductionDjango by default, has a large collection of possible types that can be used to define the
model. But sometimes we need to use some more complex types offered by PostgreSQL. In this
case, we will look the integrating of PostgreSQL array with Django.Quickstartdjorm-ext-pgarrayexposes a simple django model fielddjorm_pgarray.fields.ArrayField.
This accepts two additional parameters:dbtypethat represents a postgresql type, anddimensionthat represents a dimension of array field.This is a sample definition of model using a ArrayField:fromdjango.dbimportmodelsfromdjorm_pgarray.fieldsimportArrayFieldfromdjorm_expressions.modelsimportExpressionManagerclassRegister(models.Model):name=models.CharField(max_length=200)points=ArrayField(dbtype="int")objects=ExpressionManager()classRegister2(models.Model):name=models.CharField(max_length=200)texts=ArrayField(dbtype="text",dimension=2)# this creates `points text[][]` postgresql field.objects=ExpressionManager()Creating objectsThis is a sample example of creating objects with array fields.>>>Register.objects.create(points=[1,2,3,4])<Register: Register object>>>>Register2.objects.create(texts=[['Hello','World'],['Hola','Mundo']])<Register2: Register2 object>Using custom PostgreSQL data typesSome times we need use some other data types that postgresql offers for make arrays and
djorm-ext-pgarray does not offers builtin support for it. Now, djorm-ext-pgarray
supports a simple way to extend it:classRegister(models.Model):name=models.CharField(max_length=200)macs=ArrayField(dbtype="macaddr",type_cast=lambdax:str(x))# Same as previous line but uses str as callback directly# macs = ArrayField(dbtype="macaddr", type_cast=str)objects=ExpressionManager()If type_cast patameter is not None, ArrayField ignores the no existence of a builtin
cast function for some type and use a function passed throught type_cast argument.How install it?You can clone the repo from github and install with simple python setup.py install
command. Or use a pip, for install it from Python Package Index.pip install djorm-ext-pgarrayAdditionally, you can install djorm-ext-expressions, that can help with complex queries
using array fields.Known issuesQuerysets using expressions package can not be used as subqueries. Because alias
propagation is not working properly.
Package: djorm-ext-pgbytea
NOTE: this package is deprecated, because django after version 1.6 has support
for binaryfield nativelly.Binary field and other usefull tools for postgresql bytea field type.Simple example:fromdjango.dbimportmodelsfromdjorm_pgbytea.fieldsimportByteaField,LargeObjectFieldclassByteaModel(models.Model):data=ByteaField()classLargeObjectModel(models.Model):lobj=LargeObjectField(default=None,null=True)How to install?Install the stable version using pip by running:pipinstalldjorm-ext-pgbytea