Saravanan666/pypi-org huggingface dataset:
Package: django-postalcodes-light
A simple data model for storing postal codes with placenames and location.InstallingThe recommended installing method is withpip:pip install django-postalcodes-lightYou can also clone the repository and install from source:python setup.py installGetting dataPostal code data is available from a number of sources, typically on a country
by country basis. The United States Census Bureau maintains theGazetteer
database, including
detailed postal code data. TheGeoNames geographical databasealso provides postal code data
for international postal codes (and other places).This project uses the column names specified by GeoNames and includes a
management to import and update data from GeoNames:python manage.py import_postalcodes USAdditional files can be imported by specifying each country code. Multiple
country codes may be provided on one line, e.g.:python manage.py import_postalcodes FR IT
Package: django-postcode-lookup
This Django app providers a pluggable postcode django rest framework endpoint. It currently only works
for postcodes in The Netherlands.Currently supports the following services:ApiWiseWebservices.nlpostcodeapi.nuStatusInstallationpipinstalldjango_postcode_lookupUsageAdd the following to your urls.py:path('postcode-lookup/',include('django_postcode_lookup.urls')),Add a setting with the required backendWebservices:POSTCODE_LOOKUP={'default':{'backend':'django_postcode_lookup.backends.Webservices','OPTIONS':{'username':'someuser','password':'somepassword',}}}ApiWise:POSTCODE_LOOKUP={'default':{'backend':'django_postcode_lookup.backends.ApiWise','OPTIONS':{'api_key':'somekey',}}}postcodeapi.nu:POSTCODE_LOOKUP={'default':{'backend':'django_postcode_lookup.backends.PostcodeApiNu','OPTIONS':{'api_key':'somekey','base_url':'https://somebaseurl.com',}}}To offer some form of protection to the api endpoint for usage by others a
valid csrf token is required.
Package: django-postcss-modules
django-postcss-modulesBringpostcss-modulesto your django project, transpiling static .cssm files on the fly, without NodeJS require!Installpip install django-postcss-modulesStatic files transpiling configAddpostcss_modulesto your djangoINSTALLED_APPSAddpostcss_modules.middlewares.PostCSSModulesMiddlewareto your djangoMIDDLEWAREnote the order[
...
'postcss_modules.middlewares.PostCSSModulesMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
... 
]Config djangoSTATICFILES_STORAGE = 'postcss_modules.storage.PostCSSModulesStorage'Global OptionsDefault options is:{'polyfill':'postcss-modules-v8-polyfill.js','transpiler':'npm/postcss-modules-standalone@1.0.1/index.bundle.min.js','setup':'postcss-modules-setup.js','extensions':['.cssm'],'mimetypes':{'.cssm':'text/css'},'max_time':3# transpiling max wait time, in second}You can customize by providePOSTCSS_MODULESin your django settings, for example, custom max time:POSTCSS_MODULES = {
    'max_time': 30
}Template SupportSometimes transpiling in your template file is more make sense than static file,
you can usepostcssmodulestag to do that.{% load static postcss_modules %}
...
<style id="indexStyles">
{% postcssmodules %}
:global .page {
  padding: 20px;
}

@value hi from '{% static "myapp/css/consts.cssm" %}';

.title {
  composes: title from "{% static "myapp/css/mixins.cssm" %}";
  color: green;
}

.article {
  font-size: 16px;
  color: hi;
}
{% endpostcssmodules %}
</style>
...
<script>
  const _styles = document.querySelector('#indexStyles').sheet
  const styles = JSON.parse(_styles.cssRules[_styles.cssRules.length - 1].style.getPropertyValue('--json'));
  element.innerHTML = '<div class="' + styles.title + '">';
</script>
...Template tag also support use custom transpiling option, for example:{% postcssmodules max_time=30 %}
.title {
  composes: title from "{% static "myapp/css/mixins.cssm" %}";
  color: green;
}
{% endpostcssmodules %}FAQStatic file not get transpiledif you use djangorunservercommand to run server and the settingDEBUG=True, please add--nostaticoption to commandI want use other storageyou should write your own storage to inheritPostCSSModulesStorage
Package: django-post-fetch-hook
Django Post-fetch Hookpipinstalldjango-post-fetch-hookDocumentation:https://mrthearman.github.io/django-post-fetch-hook/Source Code:https://github.com/MrThearMan/django-post-fetch-hook/Contributing:https://github.com/MrThearMan/django-post-fetch-hook/blob/main/CONTRIBUTING.mdAdds a post-fetch hook to Django models, which can be used to modify data fetched from database via the Django ORM.
Package: django-postges-lookups-any
Provides =ANY(ARRAY(xxx)) instead of IN (xxx)DocumentationThis library is designed for Postgres. It enables developers to cope with problem when Postgres
doesn’t use indexes with longIN ()statements.Usually, when you try to do a query:SELECTa.*FROMaWHEREa.idNOTIN(SELECTb.idFROMb)You expect that it will be used index on a.id. Unfortunately, it doesn’t work.There is a trick to make Postgres do it by rewritten query this way:SELECTa.*FROMaWHEREa.id=ANY(ARRAY(SELECTb.idFROMb))This library allows you to use this statement. Examples:"""
SELECT * FROM mymodel WHERE somefield=ANY([1, 2, 3])
"""MyModel.objects.filter(somefield__any_arr=[1,2,3])"""
SELECT * FROM mymodel WHERE somefield=ANY(ARRAY(SELECT somefield FROM modelb))
"""subquery=Subquery(model_b__instances.values('somefield'))MyModel.objects.filter(somefield__any=subquery)QuickstartInstall django-postgres-lookups-any:pip install django-postges-lookups-anyAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'django_postges_lookups_any',...)Running TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ pytestDevelopment commandspip install -r requirements_dev.txtCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.0 (2021-02-08)First release on PyPI.
Package: django-postgres-backup
Django managed commands to backup and restore PostgreSQL databases with multiple generationsThedjango_postgres_backupDjango module includes managed commands to back
up and restore a PostgreSQL database with time stamped names to provide
multiple backup generations.InstallationTo install, depending on your package manager, run:pipinstall--updatedjango_postgres_backuporpoetryadddjango_postgres_backupUsageTo add the backup related managed commands to your project, add it tosettings.INSTALLED_APPS.INSTALLED_APPS=[...,"django_postgres_backup",]After this, you can backup the default database by running:pythonmanage.pypostgres_backupThe created backup can now be restored by running:pythonmanage.pypostgres_backupYou can clean and restore a whole database with all the tables and datapythonmanage.pypostgres_restore--clean--if-existsConfigurationYou can set up how many generations of backup should be saved, all other will be deleted.POSTGRES_BACKUP_GENERATIONS=3LimitationsBackup and restore works only with postgresql.LicenseCopyright (c) 2022 ITELL.SOLUTIONS GmbH, Graz, Austria.Distributed under theMIT license. For details refer to
the fileLICENSE.The source code is available fromhttps://github.com/itell-solutions/django_postgres_backup.
Package: django-postgres-createdb
Installation$[sudo]pipinstalldjango-postgres-createdbExamplesexample 1 - management command:settings.pyINSTALLED_APPS+=['django_postgres_createdb']DATABASES={'default':{'ENGINE':'django.db.backends.postgresql','NAME':os.getenv('DB_NAME'),'USER':os.getenv('DB_USER'),'PASSWORD':os.getenv('DB_PASS'),'HOST':os.getenv('DB_HOST'),'PORT':os.getenv('DB_PORT'),}}$pythonmanage.pycreatedb
$pythonmanage.pycreatedb"default"example 2 - python module cli:settings.pyDATABASES={'default':{'ENGINE':'django.db.backends.postgresql','NAME':os.getenv('DB_NAME'),'USER':os.getenv('DB_USER'),'PASSWORD':os.getenv('DB_PASS'),'HOST':os.getenv('DB_HOST'),'PORT':os.getenv('DB_PORT'),}}$exportDJANGO_SETTINGS_MODULE=settings
$python-mdjango_postgres_createdb
$python-mdjango_postgres_createdb"default"Relateddjango-postgres-createdbdjango-postgres-dropdbreadme42.com
Package: django-postgres-delete-cascade
This is a temporary workaround untilDjango’s ticket #21961is fixed. It has been tested
with Python 2.7, Django 1.6 and Psycopg2 2.6, but should work with other
combinations.To use it, you just have to:Install this distribution as a dependency. For example,pipinstalldjango-postgres-delete-cascadeReplace thedjango.db.backends.postgresql_psycopg2engine withdjango_postgres_delete_cascade. For example:DATABASES={'default':{'ENGINE':'django_postgres_delete_cascade','NAME':'mydatabase','USER':'mydatabaseuser','PASSWORD':'mypassword','HOST':'127.0.0.1','PORT':'5432',}}Change logVersion 1.0 Release Candidate 3 (2015-10-12)Fixed packaging issue.Version 1.0 Release Candidate 2 (2015-10-12)Initial release, in spite of the version (due to some problems with PYPI).
Package: django-postgres-dropdb
Installation$[sudo]pipinstalldjango-postgres-dropdbExamplesexample 1 - management command:settings.pyINSTALLED_APPS+=['django_postgres_dropdb']DATABASES={'default':{'ENGINE':'django.db.backends.postgresql','NAME':os.getenv('DB_NAME'),'USER':os.getenv('DB_USER'),'PASSWORD':os.getenv('DB_PASS'),'HOST':os.getenv('DB_HOST'),'PORT':os.getenv('DB_PORT'),}}$pythonmanage.pydropdb
$pythonmanage.pydropdb"default"example 2 - python module cli:settings.pyDATABASES={'default':{'ENGINE':'django.db.backends.postgresql','NAME':os.getenv('DB_NAME'),'USER':os.getenv('DB_USER'),'PASSWORD':os.getenv('DB_PASS'),'HOST':os.getenv('DB_HOST'),'PORT':os.getenv('DB_PORT'),}}$exportDJANGO_SETTINGS_MODULE=settings
$python-mdjango_postgres_dropdb
$python-mdjango_postgres_dropdb"default"Relateddjango-postgres-createdbdjango-postgres-dropdbreadme42.com
Package: django-postgres-extensions
Django Postgres Extensions adds a lot of functionality to Django.contrib.postgres, specifically in relation to ArrayField, HStoreField and JSONField, including much better form fields for dealing with these field types. The app also includes an Array Many To Many Field, so you can store the relationship in an array column instead of requiring an extra database table.Check outhttp://django-postgres-extensions.readthedocs.io/en/latest/to get started.
Package: django-postgres-extensions-compat
Django Postgres Extensions adds a lot of functionality to Django.contrib.postgres, specifically in relation to ArrayField, HStoreField and JSONField, including much better form fields for dealing with these field types. The app also includes an Array Many To Many Field, so you can store the relationship in an array column instead of requiring an extra database table.Check outhttp://django-postgres-extensions.readthedocs.io/en/latest/to get started.
Package: django-postgres-extensions-ng
Django Postgres Extensions adds a lot of functionality to Django.contrib.postgres, specifically in relation to ArrayField, HStoreField and JSONField, including much better form fields for dealing with these field types. The app also includes an Array Many To Many Field, so you can store the relationship in an array column instead of requiring an extra database table.Check outhttp://django-postgres-extensions.readthedocs.io/en/latest/to get started.
Package: django-postgres-extensions-up
Django Postgres Extensions adds a lot of functionality to Django.contrib.postgres, specifically in relation to ArrayField, HStoreField and JSONField, including much better form fields for dealing with these field types. The app also includes an Array Many To Many Field, so you can store the relationship in an array column instead of requiring an extra database table.Check outhttp://django-postgres-extensions.readthedocs.io/en/latest/to get started.
Package: django-postgres-extra
:white_check_mark:Tests:memo:License:package:PyPi:four_leaf_clover:Code coverageDjango Versions2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1Python Versions3.6, 3.7, 3.8, 3.9, 3.10:book:DocumentationRead The Docs:warning:UpgradeUpgrade from v1.x:checkered_flag:InstallationInstallation Guide:fire:FeaturesFeatures & Documentation:droplet:Future enhancementsPotential featuresdjango-postgres-extraaims to make all of PostgreSQL's awesome features available through the Django ORM. We do this by taking care of all the hassle. As opposed to the many small packages that are available to try to bring a single feature to Django with minimal effort.django-postgres-extragoes the extra mile, with well tested implementations, seamless migrations and much more.With seamless we mean that any features we add will work truly seamlessly. You should not have to manually modify your migrations to work with fields and objects provided by this package.:warning:This README is for v2. See thev1branch for v1.x.Major featuresSee the full listNative upsertsSingle queryConcurrency safeWith bulk support (single query)Extended support for HStoreFieldUnique constraintsNull constraintsSelect individual keys using.values()or.values_list()PostgreSQL 11.x declarative table partitioningSupports both range and list partitioningFaster deletesTruncate tables (with cascade)IndexesConditional unique index.Case sensitive unique index.Working with the codePrerequisitesPostgreSQL 10 or newer.Django 2.0 or newer (including 3.x, 4.x).Python 3.6 or newer.Getting startedClone the repository:λ git clone https://github.com/SectorLabs/django-postgres-extra.gitCreate a virtual environment:λ cd django-postgres-extra
λ virtualenv env
λ source env/bin/activateCreate a postgres user for use in tests (skip if your default user is a postgres superuser):λ createuser --superuser psqlextra --pwprompt
λ export DATABASE_URL=postgres://psqlextra:<password>@localhost/psqlextraHint: if you're using virtualenvwrapper, you might find it beneficial to put
theexportline in$VIRTUAL_ENV/bin/postactivateso that it's always
available when using this virtualenv.Install the development/test dependencies:λ pip install .[test] .[analysis]Run the tests:λ toxRun the benchmarks:λ py.test -c pytest-benchmark.iniAuto-format code, sort imports and auto-fix linting errors:λ python setup.py fix
Package: django-postgres-fuzzycount
Created byStephen McDonaldIntroductionUp until PostgreSQL 9.2,COUNTqueries generally required scanning
every row in a database table. With millions of rows, this can become
quite slow. One work-around for this is to query statistics in
PostgreSQL for an approximate row count, which in many cases is an
acceptable trade-off.Given a table calledbigdata, the following query will return an
approximate row count:SELECT reltuples FROM pg_class WHERE relname = 'bigdata';You can read more information aboutslow COUNT queries in PostgreSQLin the PostgreSQL wiki.Whatdjango-postgres-fuzzycountprovides is a way of using this
approach directly in your Django model managers. It was originally
built for displaying statistics in thekouio RSS reader, a popular alternative to Google Reader, that acquired over 5 million news articles
in its database during the first week of its launch.InstallationThe easiest way to installdjango-postgres-fuzzycountis directly
from PyPi usingpipby running the following command:$ pip install -U django-postgres-fuzzycountOtherwise you can download and install it directly from source:$ python setup.py installUsageBy using thefuzzycount.FuzzyCountManageron your Django models,
itscount()method will return an approximate value when querying
PostgreSQL tables without anyWHEREORHAVINGclauses:from django.db import models
from fuzzycount import FuzzyCountManager

class BigData(models.Model):

    big = models.BooleanField(default=True)
    data = models.TextField()

    objects = FuzzyCountManager()

BigData.objects.count()  # Uses fuzzycount
BigData.objects.filter(id__gt=9000).count()  # Doesn't use fuzzycountThefuzzycount.FuzzyCountManageralso checks the database engine
being used, and only applies the approximate count query when using
PostgreSQL, so other database backends can be used and will behave as
usual (for varying definitions ofusual, depending on the database :-).Inspirationpostgres_loose_table_counts, a Ruby gem providing the same
approach for RailsThisDjango snippet, which bakes the approach into the admin
Package: django-postgres-hot-upgrade
django-postgres-hot-upgradeLet Django clear its PostgreSQL extensions OIDs cache, making it possible to update
the PostgreSQL version to a new major version on the fly.The how$pipinstalldjango-postgres-hot-upgradeINSTALLED_APPS=[...,# Warning: django_postgres_hot_upgrade requires to be placed before# django.contrib.postgres otherwise it will not work.'django_postgres_hot_upgrade','django.contrib.postgres',...,]The whyPostgreSQL keeps internal ids of for various objects
(OIDs). This includes
loaded extentions. In order to interact with those extensions, Django needs to know
these IODs, so it loads them and, in order to avoidunneeded
requests, it caches them in memory for
the duration of the process.Several PostgreSQL servers running the same version of PostgreSQL will have consistent
OIDs but when you upgrade, OIDs can change. If one uses a PostgreSQL load balancer such
aspgbouncerorpgpool, one
could be tempted to migrate between major PostgreSQL versions on the fly, avoinding
downtime. Indeed, for sufficiently recent versions of PostgreSQL, this would work, apart
from the OID problem: if OIDs change, Django needs to update its cache.django_postgres_hot_upgradememorizes the postgres version of the server after each
connection. When the version is updated, it clears the internal Django OIDs cache,
forcing Django to fetch the new values.The restCompatibility: Please refer to versions of Python and Django tested intox.ini.License:MITCode of Conduct: This project is placed under theContributor
Coveneant. Please
report any abuse tojoachim.jablon at people-doc.com.[Maintainers] The ugly partApart from its unit tests, this package has an integration test. In order to test the
feature, we need to simulate a change of OIDs caused by a live update from PG10 to PG12
in a controlled CI environment. This is the most fragile part of the lib, and the most
likely to break in the future. Here's what you need to know:docker-compose.ymldefine two databasespostgres10andpostgres12listening on
5432 and 5433 respectively.tests/django_settings.pydefine adefaultdatabase using libpq envvars. Note that
in the settings, we requests the tests to run on the normal database instead of
dedicatedtest_<foo>database.The OIDs are created by Postgres when installing the extensions. This happens intests/migrations/0001_initial.py. TheDJANGO_REVERSE_OPERATIONSenv var controls
the order of the 2 extensions creation. Running the PG10 migration in normal order
and the PG12 migration in reverse order ensures the OIDs will be different.Theruntestsscript ensure the migrations run on both databases in the decided
order, then launches the test. Without this, the integration test would likely fail
because the OIDs would be the same in the two databases.toxcallsruntests.GitHub Actions calltox.The following work to launch tests locally:runtoxorruntestson fresh databasesrunpytestsif you know the OIDs are already properly set on the 2 databases
Package: django-postgres-ioc
IntroductionDjango ORM manager for Postgresql
Came fromRock@luojilabReplaceupdate_or_createWithout transaction, when usingupdate_or_createmay raiseIntegrityErrorBecause thread 1 execute update affect 0 row
and at the same time, thread 2 insert it
then thread 1 do insert will trigger UniqueKey conflict.This method will useINSERT ON CONFLICTfeature to fix this.RequirementsPython >= 2.6 (tested on 2.7 and 3.6)Django >= 1.7PostgreSQL >= 9.5InstallationRunning following command:$ python setup.py installOr using pip:$ pip install -U django-postgres-iocUsagePython code:from django.db import models
from ioc import IOCManager

class Test(models.Model):
    code = models.CharField(max_length=50, unique=True))
    name = models.CharField(max_length=100

    objects = IOCManager()

Test.objects.create_or_update(
    conflict="code",
    code="luojilab",
    defaults={
        "name": "LuojiLab",
    },
)
Package: django-postgres-lock
ADjangomanagement command which will run a command inside a Postgres lock, ensuring that only a
single instance of the inner command will run.InstallationUsingpip:$pipinstalldjango-postgres-lockEdit your Django project’s settings module, and add the application toINSTALLED_APPS:INSTALLED_APPS=[# ..."postgres_lock",# ...]UsageTo run clearsessions with the default lock:$./manage.pycommand_lock--./manage.pyclearsessionsTo use a unique lock for this task:$./manage.pycommand_lock--nameclearsessions--./manage.pyclearsessionsTo exit immediately if a lock can’t be acquired:$./manage.pycommand_lock--try--nameclearsessions--./manage.pyclearsessionsTo ignore a lock failure and return a successful exit code:$./manage.pycommand_lock--try--ignore-fail--nameclearsessions--./manage.pyclearsessions
Package: django-postgres-matviews
Installation$[sudo]pipinstalldjango-postgres-matviewssettings.pyINSTALLED_APPS+=['django_postgres_matviews']Examples$pythonmanage.pyrefresh_matviews
$pythonmanage.pydrop_matviews$pythonmanage.pyrefresh_matview"matview1""matview2"$pythonmanage.pydrop_matviews"matview1""matview2"fromdjango_postgres_matviews.utilsimportdrop_matview,drop_matviews,get_matviews,refresh_matview,refresh_matviewsrefresh_matviews()drop_matviews()refresh_matview('matview1')drop_matview('matview1')forminget_matviews():m.schemaname,m.matviewnamereadme42.com
Package: django-postgres-metrics
django-postgres-metricsA Django application that exposes a bunch of PostgreSQL database metrics.BackgroundAtPyCon Canada 2017Craig Kerstiensgave a talk "Postgres at any scale". In his talk Craig
pointed out a bunch of metrics one should look at to understand why a PostgreSQL database could
be "slow" or not perform as expected.This project adds a Django Admin view exposing these metrics to Django users with theis_superusersflag turned on.InstallationStart by installingdjango-postgres-metricsfrom PyPI:(env)$python-mpipinstalldjango-postgres-metricsYou will also need to make sure to havepsycopg2orpsycopginstalled which
is already a requirement by Django for PostgreSQL support anyway.Then you need to addpostgres_metricsto yourINSTALLED_APPSlist. Due to the waydjango-postgres-metricsworks, you need to include it _before* theadminapp:INSTALLED_APPS=['postgres_metrics.apps.PostgresMetrics','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',]You also need to make sure that therequestcontext processor is included in theTEMPLATESsetting. It is included by default for projects that were started on Django 1.8 or later:TEMPLATES=[{'BACKEND':'django.template.backends.django.DjangoTemplates','OPTIONS':{'context_processors':[...,'django.template.context_processors.request',...,],},},]Lastly, you need to add a URL path to your globalurls.pybeforetheadminURL patterns.fromdjango.urlsimportinclude,pathurlpatterns=[path('admin/postgres-metrics/',include('postgres_metrics.urls')),path('admin/',admin.site.urls),]This is what a metric could look like:SecurityIf you found or if you think you found a security issue please get in touch viainfo+django-postgres-metrics *at* markusholtermann *dot* eu.I'm working about this in my free time. I don't have time to monitor the email 24/7. But you
should normally receive a response within a week. If I haven't got back to you within
2 weeks, please reach out again.ContributingThe projectblackandisortfor formatting its code.flake8is used for linting. All these are
combined intopre-committo run before each commit
and push. To set it up:(env)$python-mpipinstall'.[dev,test]'(env)$pre-commitinstall-tpre-commit-tpre-push--install-hooksTo run the unit tests:(env)$django-admintest-v2--settings=tests.settings