Saravanan666/pypi-org huggingface dataset:
Package: django-gdpr-assist
Tools to help manage your users’ data in the age of GDPRhttps://github.com/wildfish/django-gdpr-assistFeaturesFind, export and anonymise personal data to comply with GDPR requestsTrack anonymisation and deletion of personal data to replay after restoring
backupsAnonymise all models to sanitise working copies of a production databaseSupports Django 2.2 to 4.0, on Python 3.6 to 3.10.See thefull documentationfor details
of how GDPR-assist works; in particular:Installation- how to installUsage- overview of how to use it with your projectUpgrading- what has changed from previous versions and how to upgradeContributing- how to contribute to the projectQuickstartInstall withpip installdjango-gdpr-assist, addgdpr_assistto
Django’sINSTALLED_APPSand add agdpr_logdefinition toDATABASES.Then start adding privacy metadata to your models:class Comment(models.Model):
    name = models.CharField(max_length=255, blank=True)
    age = models.IntegerField(null=True, blank=True)
    message = models.TextField()

    class PrivacyMeta:
        fields = ['name', 'age']
        search_fields = ['name']
        export_fields = ['name', 'age', 'message']This will allow you to anonymise and export data in this model using the
standard gdpr-assist admin tool. You can also configure anonymisation or
deletion of a related model to trigger anonymisation of your model, and can
manually register aPrivacyMetafor third-party models without modifying
their code.Anonymisation and deletion events for models registered with gdpr-assist are
logged for replay after a backup restoration with thegdpr_rerunmanagement
command. When you need to work with a copy of the production data, there is
also theanonymise_dbcommand, which will anonymise the whole database.
Package: django-gdpr-helpers
GDPR HelpersGDPR Helpers is a Django app for easy GDPR compliance.QuickstartInstall Django GDPR Helpers:pip install django-gdpr-helpersAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'gdpr_helpers',...)Define your reasons for asking personal data and assign them to a group:fromgdpr_helpers.modelsimportLegalReasonGroup,egalReasonlegal_group=LegalReasonGroup.objects.create(where="registration")LegalReason.objects.create(legal_group=legal_group,flag_text="Required for registration",slug="registration",active=True,required=True)LegalReason.objects.create(legal_group=legal_group,flag_text="Optional for registration",slug="marketing",active=True,required=False)Or use the django-admin.Add the Mixin to a form that create an object and need privacy flags, remember to save the PrivacyLog in someplace:fromdjangoimportformsfromgdpr_helpers.formsimportGDPRFormMixinfrom.modelsimportUserclassRegistrationForm(GDPRFormMixin):classMeta:model=Userwhere="registration"fields=("whatever_fields_from_model",)defsave(self):user=super().save()PrivacyLog.objects.create_log(content_object=user,cleaned_data=self.cleaned_data)returnuserNote that the privacy fields are already injected in the form.Filling the form will now create logs for the object created.FeaturesCan define Legal reason for which you are collecting personal dataCan define duration for the consentsCreate logs for the data you collected with a timestamp and what the user consented toLogs are anonymousChangelogVersion 0.5.0models.PrivacyLogNew property is_expired: if anyof the LegalReason are expired return True.models.LegalReasonGroupNew field “is_nenewable”: flag the log as renewable (duh), default to False.models.LegalReasonNew field “duration”: as we can’t have user consents for data processing for an indefinite period this will store how log we can use the data for this purpose, default to 365 days.New field “changed_at”: this is a Django auto_now field, when a LegalReason change then we must expire the corresponding log.New method check_expiration: return True if the consents is expired or the LegalReason is changedmiddleware.ConsentExpiredMiddlewareA middleware that check PrivacyLog for a user instance (so the consents given during registration) and add some context to response if True. This is mostly as an example of how to handle consents expiration, but it can be used.
Package: django-gdpr-solution
Django GDPR solutionCookieConsentintegration forDjangoWeb Framework.🚀️ Quick startInstall the packagepipinstalldjango-gdpr-solutionAddgdpr_solutiononINSTALLED_APPSINSTALLED_APPS=[...'gdpr_solution',...]Include the urlsurlpatterns=[...path('django-gdpr-solution/',include('gdpr_solution.urls')),...]--> [OPTIONAL] Remember that you can change the name path of the urlComplete the installation with migrationspythonmanage.pymakemigrations
pythonmanage.pymigrateLast step: load gdpr_solution and add templatetag on top of head tag on template{% load gdpr_solution %}<head>...
    {% gdpr_cookie_banner %}
    ...</head>📖 DependenciesCookieConsentJsrepository (orestbida/cookieconsent) for gdpr compliant cookie consent.
For customize the cookie banner and all its functionality, go to the official repo.
Package: django-gdrive-backup
django-gdrive-backupBacks up django postgres databases, local folders and S3 folders to a Google Drive folder through a google service account.encrypted-credentialsThis package uses encrypted-credentials and the instructions there could be useful. Adding the following lines tosettings.pywill initialise the packagefrom encrypted_credentials.django_credentials import add_encrypted_settings

add_encrypted_settings(globals())Create service accountRequires a Google service account with the Google Drive API enabledhttps://console.cloud.google.com/apis/credentials/serviceaccountkeyAdd to gdrive_backup installed appssettings.pyINSTALLED_APPS = [ ..
        'gdrive_backup',
    ]Store service account keyBy defaultencrypted-credentialsis used to store the key. Create a directory off the django projects BASE_DIR called credentials and save the json key.settings.pyCREDENTIAL_FOLDER = os.path.join(BASE_DIR, 'credentials')
CREDENTIAL_FILES = {
    'drive': 'service-account.json',
}Create Google Drive folder and share with service accountWith a Google Drive account create a folder and share with the email address of the service account.Ensure psql is available to python subprocessFor docker containers you may need to something similar to the following line in the Dockerfile dependent on the version of Postgres.RUN apt-get -y install postgresql-client-11Configure database backupsettings.pyBACKUP_GDRIVE_DIR = 'django_backup'Management commandspython manage.py backup_website
python manage.py restore_dbManagement pageurls.pyurlpatterns = [
                path('backup/', include('gdrive_backup.urls')),
                ....An enhanced version of the management page will be shown if the following django apps are installed'django_modals', 'django_datatables', 'django_menus', 'ajax_helpers'from the following PyPi packagesdjango-nested-modals, django-filtered-datatables, django-tab-menus, django-ajax-helpersConfigure S3 folder backupssettings.pyAWS_ACCESS_KEY_ID = id
        AWS_SECRET_ACCESS_KEY = key
        AWS_PRIVATE_STORAGE_BUCKET_NAME = bucket

        S3_BACKUP_DIRS = [('S3-source-folder1', 'google-drive-folder1'),
                          ('S3-source-folder2', 'google-drive-folder2')
        ]Configure cleaning of old datatabase backupssettings.pyBACKUP_DB_RETENTION = [{'hours': 1, 'number': 4}, 
                       {'hours': 2, 'number': 10},
                       {'days': 1, 'number': 10},
                       {'months': 1, 'number': 36},
                       ]Schedule backup with celery beatCELERY_BEAT_SCHEDULE = {
    'backup': {
        'task': 'gdrive_backup.tasks.backup',
        'schedule': crontab(hour='8-19', minute=10, day_of_week='mon-fri')
    }
}
Package: django-gem
Django GemDjango-gem is a reusable Django package that allows user to offload on-the-fly calculations
for Django models by putting them into database and providing and easy to use architecture to define,
how and when those database fields need to be refreshed.InstallationUsingpippip install django-gemUsingpoetrypoetry add django-gemThen add 'django_gem' to your INSTALLED_APPS.INSTALLED_APPS = [
    ...
    'django_gem',
]UsageFirst you will need to create a class that knows how to re-calculate your database fields.
In this package those classes are called "Cutters".Each of the methods on the cutter need to be defined asproperty,
and the names of those methods should mirror re-calculated fields on the Gem model in the format ofcut_<field_name>.Side effects on the properties define what related models should trigger recalculations on those fields.fromdjango_gems_example.gems.callbacks.authorimportAuthorCutterCallbacksfromdjango_gems_example.modelsimportAuthor,Bookfromdjango_gem.cutters.baseimportBaseCutterfromdjango_gem.decorators.cuttersimportside_effectsclassAuthorCutter(BaseCutter):instance:Author@property@side_effects((Author,[],AuthorCutterCallbacks.author),(Book,["author"],AuthorCutterCallbacks.book_author),)defcut_book_count(self):returnself.instance.books.count()Django-gem allows you to create a "satellite" model for you main one,
and define theCutterEngineMetawith the createdcutter.fromdjango.dbimportmodelsfromdjango_gems_example.gems.cutters.authorimportAuthorCutterfromdjango_gems_example.modelsimportAuthorfromdjango_gem.models.baseimportCutterEngineBaseModel,CutterEngineMetaBaseclassAuthorGem(CutterEngineBaseModel):book_count=models.IntegerField(default=0)classCutterEngineMeta(CutterEngineMetaBase):model=Authorcutter=AuthorCutterTo access these fields from the main model, you need to define a property on the model with the same name as
the Gem field name, and wrap it with agem_propertydecorator.fromdjango.dbimportmodelsfromdjango_gem.decoratorsimportgem_propertyclassAuthor(models.Model):name=models.CharField(max_length=100)@gem_propertydefbook_count(self):returnself.gem.book_countAll the calculations happen implicitly, ascutter_registrythat is populated on Django app startup
loads all the related models and attaches hooks for calculation. But, if needed, there are methods that you can
invoke directly from theSawclass. It allows refreshing a model, a queryset or an entire content type.
Package: django-general-filters
=====Django-General-Filters=====django-general-filters is a liberary of useful custom django filters.With django-general-filters you can develop django applications faster andeasier, and no need to deal with some difficult stuff about tags and filters.Detailed documentation is in the "docs" directory.Quick start-----------1. Add "generalfilters" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'generalfilters',]2. Load the general_filter filter in your templates like this::{% load general_filter %}
Package: django-general-tags
=====Django-General-Tags=====django-general-tags is a liberary of useful custom django tags.With django-general-tags you can develop django applications faster andeasier, and no need to deal with some difficult stuff about tags and filters.Detailed documentation is in the "docs" directory.Quick start-----------1. Add "generalfilters" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'generaltags',]2. Load the general_filter filter in your templates like this::{% load general_tags %}
Package: django-generate-secret-key
Simple Django application that adds a new command:pythonmanage.pygenerate_secret_key[--replace][secretkey.txt]This will generate a new filesecretkey.txtcontaining a random Django secret
key. In your production settings file, replace the hardcoded key by:# Use a separate file for the secret keywithopen('/path/to/the/secretkey.txt')asf:SECRET_KEY=f.read().strip()You can avoid hardcoding the path of the key by using:importosBASE_DIR=os.path.dirname(os.path.dirname(__file__))# Use a separate file for the secret keywithopen(os.path.join(BASE_DIR,'secretkey.txt'))asf:SECRET_KEY=f.read().strip()
Package: django-generic-admin-actions
DescriptionDjango-generic-admin-actions are admin actions without an item selection. They
work exactly like original admin actions but without taking a queryset. This is
useful for actions that are model (and not object) related or that should
manipulate model objects as a whole.InstallationInstall from pypi.org:pip install django-generic-admin-actionsGetting startedAdd generic_admin_actions to your installed apps:INSTALLED_APPS = [
    'generic_admin_actions',
    'django.contrib.admin',
    ...
]Since we overwrite the change_list.html template the app must be listed before
django’s admin-site.Use the GenericActionsMixin for your ModelAdmin classes and add some actions:from django.contrib import admin
from generic_admin_actions import GenericActionsMixin

def my_action(modeladmin, request):
    # Do some stuff here.

class MyModelAdmin(GenericActionsMixin, admin.ModelAdmin):
    ...
    generic_actions = [
        my_action,
        ...
    ]Generic admin actions working all the same as original admin actions with the
difference that their don’t take a queryset. So for more advanced setups like
actions with intermediate pages please follow django’s official documentation.UsageOn your model’s change-list-view choose the generic action from the dropdown and
press the “Go” button.
Package: django-generic-aggregation
annotate() and aggregate() for generically-related data.  also a handy function
for filtering GFK-model querysets.Use django’sGenericRelationwhere possible,
as this can make the queries generated more efficient by using a JOIN rather
than a subquery.installation# install from pypi
pip install django-generic-aggregation

# or install via git
pip install -e git+git://github.com/coleifer/django-generic-aggregation.git#egg=generic_aggregationexamplesThe examples below assume the following simple models:class Rating(models.Model):
    rating = models.IntegerField()
    object_id = models.IntegerField()
    content_type = models.ForeignKey(ContentType)
    content_object = GenericForeignKey(ct_field='content_type', fk_field='object_id')

class Food(models.Model):
    name = models.CharField(max_length=50)
    ratings = generic.GenericRelation(Rating) # reverse generic relationYou want to figure out which items are highest rated (generic_annotate)from django.db.models import Avg

food_qs = Food.objects.filter(name__startswith='a')
generic_annotate(food_qs, Rating, Avg('ratings__rating'))

# you can mix and match queryset / model
generic_annotate(food_qs, Rating.objects.all(), Avg('ratings__rating'))You want the average rating for all foods that start with ‘a’ (generic_aggregate)food_qs = Food.objects.filter(name__startswith='a')
generic_aggregate(food_qs, Rating, Avg('ratings__rating'))You want to only display ratings for foods that start with ‘a’ (generic_filter)food_qs = Food.objects.filter(name__startswith=’a’)
generic_filter(Rating.objects.all(), food_qs)documentationhttp://django-generic-aggregation.readthedocs.org/
Package: django-generic-awards
Django Generic AwardsDjango app to create and manage Awards for your Model objects.Quick startAdddjango.contrib.sites,tofanddjango_generic_awards.apps.DjangoGenericAwardsConfigto your INSTALLED_APPS setting like this:INSTALLED_APPS=[...'django.contrib.sites','tof','django_generic_awards',]Make sure that you haveSITE_IDin yoursettings.py:SITE_ID=XXRunpython manage.py migrate sitesto create example site for your project.Runpython manage.py migrateto create the django_generic_awards models.Start the development server and visithttp://127.0.0.1:8000/admin/to setup Awardable models and add new Awards.OptionalRun tests withpython runtests.pycommandSpecial ThanksTowinePad GmbHfor initiating and sponsoring of this project.
Package: django-generic-bookmarks
This application provides bookmarks management functionality to
a Django project.For instance, using bookmarks, users can store their favourite
contents, or items they follow, or topics they like or dislike.A bookmark connects users to Django contents in a generic way, without
modifying existing models tables, anddjango-generic-bookmarksexposes
a simple API to handle them, yet allowing the management of bookmarks
in complex scenarios too.The bookmarks can be stored using different backends.
The default one uses Django models to store user’s preferences in the database,
but it is possible to write customized backends, and the application,
out of the box, includes also a MongoDB backend.The source code for this app is hosted onhttps://bitbucket.org/frankban/django-generic-bookmarksDocumentationis avaliableonlineand in the docs directory of the project.
Package: django-generic-confirmation
Django-generic-confirmation makes it easy for developers to add forms to a
webapplication where the submitted data should only be used after an out-of-band
confirmation was done. For example if a user wants to change his email address,
generic-confirmation will make it really easy for the developer to add an
out-of-band confirmation process (sending an email with a random link to the
user) before saving the new email address to the database.The core of django-generic-confirmation is fully unit-tested and the app is in
use at a few real-world projects confirming email addresses and mobile phone
numbers. Feel free to read about the usage indocs/usage.txtor onhttp://django-generic-confirmation.readthedocs.org.django-generic-confirmation 0.4.x is compatible with Django 1.8 - 1.11.
Package: django-generic-contact
Django Generic ContactDjango module to store contact request in a structured yet generic manner within the database.InstallationInstall using pip:pipinstalldjango-generic-contactIntegratedjango_generic_contactinto yoursettings.pyINSTALLED_APPS=[# ...'django_generic_contact',# ...]UsageThe package provides you with aContactmodel which expectsdata(dict) and thenameof the requester,
an optionalmessagecan be added:from django_generic_contact.models import Contact

contact = Contact.objects.create(
    name="Mr. Tester",
    message="Please contact me via email or phone.",
    data={
        "email": "mr@tester.com",
        "phone": "123456",
    }
)JSON Schema validationThe contents ofdatawill be validated against ajson schemadefined in your project'ssettings.py(if provided). If needed you can defineGENERIC_CONTACT_DATA_SCHEMAto check all relevant input
according to the expected structure, e.g.:GENERIC_CONTACT_DATA_SCHEMA = {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "email": {"type": "string", "format": "email"},
        "phone": {"type": "integer"},
    },
}See more examples ofGENERIC_CONTACT_DATA_SCHEMAintests/testapp/tests/test_model.py.Customizing the Contact modelThe base modelGenericContactonly requires thedata. Thus you can let your own models inherit from this and extend
it according to your project's needs, e.g.:from django_generic_contact.models import GenericContact

class CustomContact(GenericContact):
    birth_date = models.Datetime(_("birth date"))
    zip = models.CharField(_("zip"))Unit TestsSee foldertests/. The provided tests cover these criteria:success:Contact model instance creationproject's jsonschema validationfailure:project's jsonschema validationexemplary custom jsonschema validationFollow below instructions to run the tests.
You may exchange the installed Django and DRF versions according to your requirements.
:warning: Depending on your local environment settings you might need to explicitly callpython3instead ofpython.# install dependenciespython-mpipinstall--upgradepip
pipinstall-rrequirements.txt# setup environmentpipinstall-e.# run testscdtests&&pythonmanage.pytestContributingContributions are welcomed! Read theContributing Guidefor more information.LicensingSeeLICENSEfor more information.
Package: django-generic-delete
Soft DeleteInstallationpip install django-softdeleteConfigurationINSTALLED_APPS=[...,'softdelete',]in urlsurlpatterns=[....path('delete/',include('softdelete.urls',namespace='softdelete'))]UsageIn modelsExtend# import thisfromsoftdelete.modelsimportSoftDeletionModelclassYourModel(SoftDeletionModel):# your fieldspassOverride templatesin yourtemplatesadd the following directorytemplates/
    softdelete/
      delete.configuration.html
Package: django-generic-feeds
A simple way for objects to subscribe to other objects for a “feed-like”
functionality in a Django project.Installationpip installdjango-generic-feedsorRunsetup.py installor add to your Python path and include'feeds'in yourINSTALLED_APPSsetting.UsageMake a new feed:from feeds.models import Feed

feed = Feed.objects.create()Add a subscription to a feed:from myapp.models import Event

event = Event.objects.get(pk=36)
feed.add_subscription(event)Then you can add an activity:from feeds.models import add_activity

add_activity(actor=request.user, verb='attended', obj=event)Then the feed’s activity will be populated with this activity:print feed.activity.all()See the source code for more.Need Help?Email:rvause@gmail.comGithub:https://github.com/rvause/django-generic-feeds
Package: django-generic-file
A Generic File Model for all kind of file attachment with AJAX fileupload and drag & drop feature.Attach files to any Model across your projectInclude file upload field in your django templates using our templatetagsRetrieve back the list of files attached to your Object using our templatetagsInstallationpip install django-generic-fileUsageAdd“genericfile”to your INSTALLED_APPS and migrate.Include following static files in your template:<link rel="stylesheet" type="text/css" href="{% static 'genericfile/genericfile.css' %}">
<script src="{% static 'genericfile/genericfile.js' %}"></script>At the top of your template load our template tags:{% load genericfiletags %}Then to render your formIn Your Add Form (basically where object is not yet created / unknown):<form action='.' method='post'>
    {% csrf_token %}
    {{ form }}
    {% get_genericfile_form %}
    <button type='submit' class="btn blue">Submit</button>
</form>

# then in POST method of your view,
from genericfile.views import update_genericfile
update_genericfile(self.request.POST, self.object)In Your Edit Form (where object is known):<form action='.' method='post'>
    {% csrf_token %}
    {{ form }}
    {% get_genericfile_form host_object=form.instance %}
    <button type='submit' class="btn blue">Submit</button>
</form>OptionsmaxFileCount- to Restrict Number of files:{% get_genericfile_form maxFileCount=1 %}

# Default is NoLimitallowedTypes- to Restrict File types:{% get_genericfile_form allowedTypes="jpg,jpeg,png,gif,doc,pdf,zip,html,txt,docx" %}

# Default is AnyFilesTo get the list of files in Details view{% get_genericfile_list host_object=object as attachments %}
<ul>
  {% for file in attachments %}
    <li><a href="{{file.attachment.url}}" target="_blank">{{file.get_name}}</a></li>
  {% empty %}
    <li>No files found</li>
  {% endfor %}
</ul>Additional RequirementsInclude if you not have included them already in you html file<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>