Saravanan666/pypi-org huggingface dataset:
Package: django-chronicle
Django Chronicle is an implementation of the slowly changing dimensions type 4
which uses database triggers.How to use?1.) Create a custom revision model. e.g.from chronicle.models import AbstractRevisionclass Revision(AbstractRevision):user = models.ForeignKey(settings.AUTH_USER_MODEL)
created = models.DateTimeField(auto_now_add=True)2.) Set settings.REVISION_MODEL to point to your revision model. e.g.REVISION_MODEL = ‘revision.Revision’3.) Let your models inherit fromHistoryMixine.g.from chronicle.models import HistoryMixin
from django.db import modelsclass Food(HistoryMixin, models.Model):name = models.CharField(max_length=50)4.) Create all the migrations and run them:$ manage.py makemigrations
$ manage.py migrateThat should create all the_historytables for your models
that inherit from theHistoryMixin.5.) Create the database triggers$ manage.py create_history_triggersNow every change to your models should be logged in the_historytables
and you can access the model history via theHistorymodel which becomes
a field of the original class.Example usage:# create
food = Food(‘Carot’)
food.save()
assert(Food.History.objects.filter(id=food.id).count() == 1)# update
food.name = ‘Carrot’
food.save()
assert(Food.History.objects.filter(id=food.id).count() == 2)# delete
food.delete()
assert(Food.History.objects.filter(id=food.id).count() == 3)Why database triggers?The obvious choice to implement model history would be to connect a signal
handler to thepost_saveandpost_deletesignal. This has some rather huge
downsides:1.)QuerySet.update()and a lot of otherQuerySetmethods do not emit any
signals. Having to limit the code to only usesave()can be a rather huge
performance problem depending on the type of application.2.) There is a rather large performance impact when creating the history via
the Django ORM. A singleQuerySet.update()call could result in hundreds
or thousands of inserts. While this could mostly be solved using theManager.bulk_createmethod a database trigger is a lot faster as there is no
extra database roundtrip required.3.) This works for any kind of raw query - even outside of the Django ORM - as
long as thechronicle.revision_idsession variable is properly set.The only real downside is the DB compatibility. Right now this package only
supports the PostgreSQL database engine.How to issue queries without the Django ORM?Create a revision by inserting a row into the revision table and set thechronicle.revision_idsession variable like so:SET chronicle.revision_id = 42; – replace 42 by the actual revision idOnce you have made all changes to your models don’t forget to reset the
session variable. Otherwise you might reuse the same revision by accident
in the same DB session:SET chronicle.revision_id TO DEFAULT;
Package: django-chronograph
ChronographControldjango-admincommands via the web.Creating cron jobs for Django apps can be a pain, annoying and repetitive. Withdjango-chronographyou simply create a single cron job to run every minute,
point it at your site’s directory and runmanage.py cron. Then from the admin
you can add jobs.Notedjango-chronographsupports Django 1.1+.Installation and UsageRead docs/overview.txt for more information, build the documentation with
Sphinx or view them onlinehere.You can also grab the latest release from PyPI:pip install django-chronograph
Package: django-chronograph-ispm
ChronographControldjango-admincommands via the web.Creating cron jobs for Django apps can be a pain, annoying and repetitive. Withdjango-chronographyou simply create a single cron job to run every minute,
point it at your site’s directory and runmanage.py cron. Then from the admin
you can add jobs.Notedjango-chronographsupports Django 1.1+.Installation and UsageRead docs/overview.txt for more information, build the documentation with
Sphinx or view them onlinehere.You can also grab the latest release from PyPI:pip install django-chronograph
Package: django-chronograph-ispm-new
ChronographControldjango-admincommands via the web.Creating cron jobs for Django apps can be a pain, annoying and repetitive. Withdjango-chronographyou simply create a single cron job to run every minute,
point it at your site’s directory and runmanage.py cron. Then from the admin
you can add jobs.Notedjango-chronographsupports Django 1.1+.Installation and UsageRead docs/overview.txt for more information, build the documentation with
Sphinx or view them onlinehere.You can also grab the latest release from PyPI:pip install django-chronograph
Package: django-chunkator
Chunk large QuerySets into small chunks, and iterate over them without killing
your RAM.Tested with all the combinations of:Python: 3.5, 3.6, 3.7, 3.8Django: 2, 2.1, 2.2, 3.0, masterNoteDjango 3.0 is incompatible with Python 3.5, see <https://docs.djangoproject.com/en/3.0/releases/3.0/#python-compatibility>Usagefromchunkatorimportchunkatorforiteminchunkator(LargeModel.objects.all(),200):do_something(item)This tool is intended to work on Django querysets.Your modelmustdefine apkfield (this is done by default, but
sometimes it can be overridden) and this pk has to be unique.django- chunkatorhas been tested with PostgreSQL and SQLite, using regular PKs and
UUIDs as primary keys.You can also usevalues():fromchunkatorimportchunkatorforiteminchunkator(LargeModel.objects.values('pk','name'),200):do_something(item)ImportantIf you’re usingvalues()youhaveto add at least your “pk” field
to the values, otherwise, the chunkator will throw aMissingPkFieldException.WarningThis will notaccelerateyour process. Instead of having one BIG query,
you’ll have several small queries. This will save your RAM instead, because
you’ll not load a huge queryset result before looping on it.If you want to manipulate the pages directly, you can usechunkator_page:fromchunkatorimportchunkator_pagequeryset=LargeModel.objects.all().values('pk')forpageinchunkator_page(queryset,200):launch_some_task([item['pk']foriteminpage])LicenseMIT License.
Package: django-chunks2
Install using pip$pipinstalldjango-chunks2Add thechunksapplication toINSTALLED_APPSin your settings file (usuallysettings.py)Sync database (./manage.py syncdbor./manage.py migrate)Use chunks on your templates{% load chunks %}<html><head><title>Test</title></head><body><h1>Blah blah blah</h1><divid="sidebar">...</div><divid="left">{% chunk "home_page_left" %}</div><divid="right">{% chunk "home_page_right" %}</div></body></html>
Package: django-chunk-upload-handlers
This library provides two Django file upload handlers.The first of these,s3provides chunk uploading to an AWS S3 bucket and is heavily based onhttps://pypi.org/project/s3chunkuploader/The second provides chunk uploading to a ClamAV rest endpoint provided by -https://github.com/uktrade/dit-clamav-rest/although it could be used with other compatible projects.If used together, the results of the anti virus check are written to the object uploaded to S3.Installationpipinstalldjango-chunk-upload-handlersUsageUsing in a Django logging configuration:INSTALLED_APPS=[..."django_chunk_upload_handlers",]FILE_UPLOAD_HANDLERS=("django_chunk_upload_handlers.clam_av.ClamAVFileUploadHandler","django_chunk_upload_handlers.s3.S3FileUploadHandler",)# Order is importantDependenciesThis project is a Django app and depends on the Django package.Thes3file handler depends onboto3anddjango-storagessettings.DEFAULT_FILE_STORAGEmust be set to"storages.backends.s3boto3.S3Boto3Storage"or a class that derives from it.SettingsS3AWS_ACCESS_KEY_IDCHUNK_UPLOADER_AWS_ACCESS_KEY_IDProvide either for the AWS access key optional.CHUNK_UPLOADER_AWS_ACCESS_KEY_IDis preferred if both are set.AWS_SECRET_ACCESS_KEYCHUNK_UPLOADER_AWS_SECRET_ACCESS_KEYProvide either for the AWS access secret key optional.CHUNK_UPLOADER_AWS_SECRET_ACCESS_KEYis preferred if both are set.AWS_STORAGE_BUCKET_NAMECHUNK_UPLOADER_AWS_STORAGE_BUCKET_NAMEThe S3 bucket to use for uploads.CHUNK_UPLOADER_AWS_STORAGE_BUCKET_NAMEis preferred if both are set.AWS_REGIONCHUNK_UPLOADER_AWS_REGIONThe AWS region to use.CHUNK_UPLOADER_AWS_REGIONis preferred if both are set.S3_ROOT_DIRECTORYCHUNK_UPLOADER_S3_ROOT_DIRECTORYThe directory path to use as root for uploads.CHUNK_UPLOADER_S3_ROOT_DIRECTORYis preferred if both are set.CHUNK_UPLOADER_RAISE_EXCEPTION_ON_VIRUS_FOUNDDefines whether or not to throw an exception if a virus is found. Defaults toFalse.ClamAVCLAM_AV_USERNAMEThe ClamAV service username.CLAM_AV_PASSWORDThe ClamAV service password.CLAM_AV_DOMAINThe domain to use for the ClamAV service. Note, this is domain only sotest.comrather thanhttps://test.comCLAM_PATHThe path to the ClamAV service (used with the domain defined in the setting above). Defaults to/v2/scan-chunkedCLAM_AV_IGNORE_EXTENSIONSA list of file extensions to not process with ClamAV. Defaults to an empty list.CLAM_USE_HTTPUse http rather than https. Should not be used in production environments. Defaults toFalse.Usage with file fieldsThe package provides a validator for use with form and model fields.TheCHUNK_UPLOADER_RAISE_EXCEPTION_ON_VIRUS_FOUNDshould not be set toTruewhen using this validator.fromdjangoimportformsfromdjango_chunk_upload_handlers.clam_avimportvalidate_virus_check_resultclassExampleForm(forms.Form):example_form_field=forms.FileField(validators=[validate_virus_check_result,])fromdjango.dbimportmodelsclassExampleModel(models.Model):example_model_field=models.FileField(max_length=10,validators=[validate_virus_check_result,],)The validation message will display ‘A virus was found’ if a virus is detected. This message is a translation string.Tests$pipinstall-rrequirements.txt$tox
Package: django-chunky-upload
This simple django app enables users to upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted.This app is intended to work withJQuery-File-UploadbySebastian Tschan(documentation).License:MIT-ZeroThis is forked from the wonderful work done indjango-chunked-upload.InstallationInstall via pip:pipinstalldjango-chunky-uploadAnd then add it to your DjangoINSTALLED_APPS:INSTALLED_APPS=(# ...'chunky_upload',)Typical usageAn initial PUT request is sent to the url linked toChunkedUploadView(or any subclass) with the first chunk of the file. The name of the chunk file can be overriden in the view (class attributefield_name). Example:{"my_file":"<File>"}In return, server will respond with theupload_id, the currentoffsetand the when will the upload expires (expires). Example:{"upload_id":"5230ec1f59d1485d9d7974b853802e31","offset":10000,"expires":"2013-07-18T17:56:22.186Z"}Repeatedly PUT subsequent chunks using theupload_idto identify the upload to the url linked toChunkedUploadView(or any subclass). Example:{"my_file":"<File>"}Server will continue responding with theupload_id, the currentoffsetand the expiration date (expires).Finally, when upload is completed, a POST request is sent to the url linked toChunkedUploadView(or any subclass). This request must include the themd5checksum (hex). Example:{"md5":"fc3ff98e8c6a0d3087d515c0473f8677"}If everything is OK, server will respond with status code 200 and the data returned in the methodget_response_data(if any).Possible error responses:User is not authenticated. Server responds 403 (Forbidden).Upload has expired. Server responds 410 (Gone).upload_iddoes not match any upload. Server responds 404 (Not found).No chunk file is found in the indicated key. Server responds 400 (Bad request).Request does not containContent-Rangeheader. Server responds 400 (Bad request).Size of file exceeds limit (if specified). Server responds 400 (Bad request).Offsets does not match. Server responds 400 (Bad request).md5checksums does not match. Server responds 400 (Bad request).Helpful LinksDocumentationSourcePyPI
Package: djangochurch-contact
Simple contact form for Django Church sites.InstallationInstall the package withpip:pip install djangochurch-contactAdddjangochurch_datatoINSTALLED_APPS:INSTALLED_APPS = [
    ...
    'djangochurch_data',
]Run the following commands:python manage.py loaddata djangochurch_pages djangochurch_assets djangochurch_events djangochurch_news
python manage.py djangochurchimagesImagesAll images used in this project are provided byUnsplash, who provide their
images under aCreative Commons Zero license.
Package: djangochurch-data
Sample content for Django Church sites.InstallationInstall the package withpip:pip install djangochurch-dataAdddjangochurch_datatoINSTALLED_APPS:INSTALLED_APPS = [
    ...
    'djangochurch_data',
]Run the following commands:python manage.py loaddata djangochurch_pages djangochurch_assets djangochurch_events djangochurch_news
python manage.py djangochurchimagesImagesAll images used in this project are provided byUnsplash, who provide their
images under aCreative Commons Zero license.
Package: django-cid
Logging is important. Anyone who has had a call at 3am to say the site
is down knows this. Without quality logging it is almost impossible to
work out what on earth is happening.The more you log, the harder it is to track down exactly what the
effects of a particular request are. Enter Django Correlation ID.
Incoming requests are assigned a unique identifier. This can either
happen in your public facing web server (e.g. nginx) or be applied
by Django itself.This correlation id (also known as request id) is then available
through the Django request/response cycle and may be automatically
included in all log messages. That way, you can easily link all log
messages that relate to the same request:2018-10-01T08:18:39.86+00:00 correlation_id=2433d5d4-27a3-4889-b14b-107a131368a3 Call to plug from cpoint=1
2018-10-01T08:18:39.90+00:00 correlation_id=72fbd7dd-a0ba-4f92-9ed0-0db358338e86 Call to state by cpoint=2 with {'state': {'B': 'idle', 'A': 'on_charge'}}
2018-10-01T08:18:39.92+00:00 correlation_id=2433d5d4-27a3-4889-b14b-107a131368a3 Ended rental=7 customer="John Smith" on plugIn this example, we can see that the first and the third log messages
are tied to the same request, while the second message relates to a
distinct request.In addition to these logs,django-cidcan include the correlation
id:in all SQL queries (as a comment);in rendered templates;as a header in the HTTP response generated by Django;and possibly anywhere by using the API ofdjango-cid, for
example as an HTTP header on a request to another internal system of
yours, which is especially useful in service-oriented architecture.Documentation can be found at:https://django-correlation-id.readthedocs.org/Sources are on GitHub:https://github.com/Polyconseil/django-cidSupported versionsWe currently support Python >= 3.6 and Django >= 2.2.Other versions may work but are not supported.
Package: django-cidr-allowed-hosts
A Django middleware that allows you to specify a list of allowed hosts
using CIDR notation.InstallationInstall using pip:pip install django-cidr-allowed-hostsAdd the middleware at the top of yourMIDDLEWAREsettings:MIDDLEWARE=['cidr.middleware.CIDRMiddleware',...]Add theCIDR_ALLOWED_HOSTSsetting to your settings:CIDR_ALLOWED_HOSTS=["0.0.0.0/0"]# allows any IPv4And that should be it.FeaturesALLOWED_HOSTSwill still work as expected. Since the middleware
overrides theALLOWED_HOSTSsetting to"*", the value
provided originally toALLOWED_HOSTSwill be stored inORIGINAL_ALLOWED_HOSTSand used to check if the request should be
allowed.IfCIDR_ALLOWED_HOSTSis not set, the middleware will not be
used.IfALLOWED_HOSTScontains"*"andCIDR_ALLOWED_HOSTSis
set, the middleware will raiseMiddlewareNotUsedexception.CIDR_ALLOWED_HOSTSmust follow theCIDR
notation.Only IPv4 is supported.Developmentpython3 -m virtualenv venv
source venv/bin/activate
pip3 install tox
toxCreditsThis project was inspired bydjango-allow-cidr
Package: django-cidrfield
cidrfieldprovides a model field fordjangothat allows the storage of an ip network on the db side by usingipaddressto handle conversion to anipaddress.ip_networkinstance (orNone)
on the python side. It supports the use of__containsand__into query the IP network that contain and belong to.InstallationAdd this to your django project by installing withpip:pip install django-cidrfieldUsageIn your models, do something like the following:from django.db import models
from cidrfield.models import IPNetworkField

class MyModel(models.Model):

    # the regular params should work well enough here
    ip_network = IPNetworkField()
    # ... and so onThen you can store a ip network like the following:MyModel(ip_network='192.168.1.0/24').save()And you can query a ip network like the following:MyModel.objects.filter(ip_network='192.168.1.0/24')
MyModel.objects.filter(ip_network__contains='192.168.1.1')
MyModel.objects.filter(ip_network__in='192.168.0.0/16')
MyModel.objects.filter(ip_network__in=['192.168.0.0/16', '10.10.0.0/16'])If you useDjangoQL, you can useCIDRQLSchemalike the following:from django.contrib import admin
from djangoql.admin import DjangoQLSearchMixin
from cidrfield.schemas import CIDRQLSchema
from .models import MyModel


@admin.register(MyModel)
class MyModelAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
    list_display = ['ip_network']
    search_fields = ('ip_network', )
    djangoql_schema = CIDRQLSchemaChangelog0.2.0Add support for Djangoql.Fixed the bug about__inquery not supporting array.
Package: django-ci-emailfield
Really simple Django ORM field for case insensitive email addressesUses CITEXT on PostgreSQL and lowercases the values on other databasesSeehttps://groups.google.com/d/msg/django-developers/SW7_qI81G58/Mdw65BhEBAAJUsage:from django.db import models
from django_ciemailfield import CiEmailField

class User(models.Model):
    email = CiEmailField(unique=True)
Package: django-citations
Citations is a simple Django app which lets you use a citations and
reference lists within your templates.The source code is available fromhttps://github.com/will-hart/django-citationsunder an MIT license.You can find the package on the Python Packing Indexhttps://pypi.python.org/pypi/django-citations/.The latest documentation for thedevelopbranch is available fromhttp://django-citations.readthedocs.org/en/latest/Quick startInstall using:pip install django-citationsAdd “citations” to your INSTALLED_APPS setting like this:INSTALLED_APPS = (
    ...
    'citations',
)Runpython manage.py migrateto create the models.UsageYou can use the admin panel to create references for your site.  These can
have a range of details including ISBN, URLs, titles, etc. Each reference
must have a unique slug.  This is how we will refer to the reference when we
cite it within a template.To refer to a reference in your database, you first need to load the tags in
your template:{% load citation_tags %}You can then do the following in your template where you want the reference to
appear:{% cite "my_reference_slug" %}You can refer to multiple references at a time by just adding new slugs separated by spaces.
Note that quotation marks are required around the slugs, and slug names should not contain
spaces:{% cite "my_first_reference_slug" "my_second_reference_slug" %}If you attempt to reference a work that is not in your reference list a TemplateSyntaxError
will be raised showing the offending reference slug.The references will be included in text as numbers - e.g.[1], or[1, 2]for multiple
references.  Reference objects will also be placed in thereference_listvariable of the
template’s context.A reference list can be included at the bottom of the document:{% show_references reference_list %}Importing ReferencesIf you have the packagebibtexparserinstalled then you will have access in the admin
panel to an “Upload Bibtex” button.  This feature will upload a bibtex file, scan it for
fields that django-citations supports and save new records.The bibtexparser package is provided under the LGPL.Change LogVersion 0.3Improved documentationAdd new fields to databaseAdd bibtex upload function, wherebibtexparseris installedAddshow_all_referencestag for complete bibliographyVersion 0.2.1Fix tags in READMEVersion 0.2Improved citation database - more fields availableImproved reference output (uses a Harvard referencing format)Version 1.0Initial version
Package: django-citext
Django CITextPostgreSQL CIText integration for Django.Setuppython3 -m pip install django-citext# settings.pyINSTALLED_APPS=['citext',# ...]Usage# myapp/models.pyfromdjango.dbimportmodelsfromcitextimportCITextField,CIEmailFieldclassMyModel(models.Model):name=CITextField()email=CIEmailField(unique=True)# myapp/views.pyfromdjango.httpimportHttpResponse,HttpResponseNotFoundfrom.importmodelsdefmy_view(request,email):try:my_model=models.MyModel.objects.get(email=email)exceptmodels.MyModel.DoesNotExist:returnHttpResponseNotFound()returnHttpResponse(my_model.name)CreditsProject is based on the Django's own CIText implementation,
which was removed in Django 5.0. Big thanks to the Django contributors
for their excellent work.
Package: django-cities-teryt
Polish region and city data for Django.This app provides models, admin integration and commands to import region and city data in your database.The data is pulled fromTERYTdatabase
(National Official Register of the Territorial Division of the Country). TERYT is maintained by
Polish Central Statistical Office (GUS)Database contains:provincescountiesmunicipalitiesvillagescitiescity districtsInstallationInstall django-cities-terytpipinstalldjango-cities-terytOr dev versionpipinstall-egit+git@github.com:lukaszbanasiak/django-cities-teryt.git#egg=cities_terytAddcities_terytto yourINSTALLED_APPSINSTALLED_APPS=(...'cities_teryt',)Now, runsyncdb, it will only create tables for models./manage.pysyncdbConfigurationDownloadSIMCandTERCxml files from TERYT websitehttp://www.stat.gov.pl/broker/access/prefile/listPreFiles.jspaand save them to one directory.Setup in yoursettings.pyfull path to above directory# Default directory is `import` dir in `django-cities-teryt` app directoryCITIES_TERYT_IMPORT_DIR='/path/to/dir'Importing dataTo populate your database with all TERYT data use command./manage.pycities_teryt--dataall--importTo remove data use command./manage.pycities_teryt--dataall--flushTo operate on specific type of data enumerate them after--dataargument./manage.pycities_teryt--dataprovince,county,municipality--import./manage.pycities_teryt--datacity,village,district--flushNoticeData have relations so it’s best to import everything.
Data are large and take time to import (there’s no progress display).
Verbosity is controlled through LOGGING.ExamplesGetCityby name>>>City.objects.get(name='Swarzędz')<City:Swarzędz(0971502)>To get name ofMunicipalityof this City we can useparentmethod or call directlymunicipalityattrib>>>City.objects.get(name='Swarzędz').parent<Municipality:Swarzędz(302116)>>>>City.objects.get(name='Swarzędz').municipality<Municipality:Buk(302103)>>>>Municipality.objects.get(city__name='Swarzędz')<Municipality:Swarzędz(302116)>In this way we can get alsoProvinceorCounty>>>City.objects.get(name='Swarzędz').province<Province:wielkopolskie(30)>>>>Province.objects.get(city__name='Swarzędz')<Province:wielkopolskie(30)>… or evenDistricts>>>c=City.objects.get(name='Swarzędz')>>>c.district_set.all()[<District:NowaWieś(0971519)>,<District:Zieleniec(0971525)>]>>>District.objects.filter(city=c)[<District:NowaWieś(0971519)>,<District:Zieleniec(0971525)>]List allCitiesin the sameCounty>>>County.objects.get(city__name='Swarzędz').city_set.all()[<City:Buk(0970520)>,<City:MurowanaGoślina(0971152)>,<City:Kostrzyn(0970885)>,<City:Mosina(0971057)>,<City:Pobiedziska(0971287)>,<City:Puszczykowo(0971376)>,<City:Kórnik(0970922)>,<City:Swarzędz(0971502)>,<City:Luboń(0970974)>,<City:Stęszew(0971494)>]Get pretty display name# Village, Municipality, County, Province>>>printVillage.objects.get(name='Kaczkowo',province__name='wielkopolskie').get_display_name()Kaczkowo,Rydzyna,leszczyński,wielkopolskie# `Municipality` and `County` for "Poznań" is the same so we got only `City` and `Province` name>>>printCity.objects.get(name='Poznań').get_display_name()Poznań,wielkopolskieRequirementsSeerequirements.txt