Saravanan666/pypi-org huggingface dataset:
Package: django-unused-media
Delete unused media files from Django projectPackage provides management commandcleanup_unused_mediafor Django
applications.You can remove all not used media files (files without references from
any Django model withFileFieldorImageFieldfields or their
inheritances).InstallationInstalldjango-unused-media:pip installdjango-unused-mediaPython2.7,3.6,3.7,pypyare tested with tox.Django1.8,1.9,1.10,1.11,2.0,2.1,2.2,3.0are tested with tox.Adddjango-unused-mediatoINSTALLED_APPS:python     INSTALLED_APPS = (         ...         'django_unused_media',         ...     )UsageTo cleanup all unused media files, run management command:./manage.py cleanup_unused_mediaBy default command is running in interactive mode. List of files which
are going to be removed will be displayed for confirmation. User has to
confirm the action.Options--noinput,--no-inputNon interactive mode. Command will remove files without any confirmation
from the user. Useful for scripts../manage.py cleanup_unused_media --noinput-e,--excludeTo avoid operating on particular files you can use exclude option. -``*`` as any symbol is supported.-Can use multiple options in one
command.For example, to keep.gitignoreand*.pngfiles you can use:./manage.py cleanup_unused_media -e *.gitignore -e *.pngAlso you can exclude entire folder or some files in that folder (path
should be relative tosettings.MEDIA_ROOT):./manage.py cleanup_unused_media -e path/to/dir/* -e path/to/dir/my*.doc--minimum-file-age, secondsDefault = 60 (one minute)Minimum file age to consider for cleanup. All files younger this age
will be skipped.--remove-empty-dirsBy default script keeps empty dirs in media folder. But with this option
all empty directories will be removed after cleaning process
automatically.--dry-runDry run without any affect on your data--verbosity{0,1,2},-v{0,1,2}Verbosity level. - 0 - silent - 1 - normal output (default) - 2 -
verbose output (list individual files)TestsAt first make sure that you are in virtualenv if you use it.Install all dependencies:make setupTo run tests:make testTo run static analyser:make flake8LicenseMIT licence
Package: django-uocLTI
Django-uocLTI is an app for interfacing django apps to LMS platforms, created for use at the Universitat Obert de Catalunya (UOC).  This app turns a django project into an LTI provider, creating a user and an associated profile with fields based on the Consumer-provided LTI fields (ims-lti).The app is more-or-less just an example of how to set up a django project for processing an LTI request from the consumer, using theims-lti-py library, along with a simple profile model to save the fields of interest.Installation and SetupRun setup.py to install uocLTI and its dependencies.  Then, add ‘uocLTI’ to installed apps in your settings and run syncdb to add the profile table.Add the following line to your main urls.py file:url(r'^uocLTI/', include('uocLTI.urls')),Settings:- CONSUMER_URL: This field is not currently being used.
- CONSUMER_KEY: Used for authentication, along with LTI_SECRET (required)
- LTI_SECRET: Used for authentication, along with CONSUMER_KEY (required)
- VELVET_ROLES: List of roles which are allowed access to the app  (optional: if not set, any role is allowed entry)
- VELVET_ADMIN_ROLES: List of roles which are added as administrators (optional: make sure these are rock solid, they set is_staff=True, is_superuser=True thereby giving full access to the app. If not set no users entering via LTI will have staff or superuser privaledges)
- AUTH_PROFILE_MODULE: Set by default to 'uocLTI.LTIProfile', make sure this is not overridden in settings.  If you are going to be using another custom profile model, then you'll need to remove the code related to the profile fields in views.py.LTI_DEBUG: Set by default to FalseLOGIN_REDIRECT_URL: set to URL for redirect after successful loginUsageThe launchurl ishttp://<domain>/uocLTI/launch_lti/.  The launch_lti view processes the request and creates a new user and an associated profile if the user does not exist, else the user is logged in and redirected to the LOGIN_REDIRECT_URL url as defined in the project settings.
Package: django-update-cache
django-update-cacheLazy cache updates for Django.RationaleCache function results with optional asynchronous updates.SupportSupports: Python 3.10.Supports Django Versions: 4.2.7Installation$pipinstalldjango-update-cacheUsageAddupdate_cache.apps.UpdateCacheConfigtoINSTALLED_APPS.Run migrations:pythonmanage.pymigrateAdd a modulecached_functionsto one or more of your apps. Decorate any function for which you want the results to be
cached:# cached_functions.pyfromupdate_cache.decoratorsimportcache_function@cache_function()defmy_expensive_function():...Specify a specific timeout:# cached_functions.pyfromupdate_cache.decoratorsimportcache_function@cache_function(timeout=60)defmy_expensive_function():...Use asynchronous updating (this requires running a django_rq worker):# cached_functions.pyfromupdate_cache.brokersimportasync_brokerfromupdate_cache.decoratorsimportcache_function@cache_function(broker=async_broker)defmy_expensive_function():...Use a custom cache backend:# cached_functions.pyfromupdate_cache.decoratorsimportcache_function@cache_function(backend='my_cache_alias')defmy_expensive_function():...You can set a global broker to delegate the cache updates insettings.py.DUC_DEFAULT_BROKER='update_cache.brokers.AsyncBroker'Invalidate the cache:# cached_functions.pyfromupdate_cache.decoratorsimportcache_function@cache_function()defmy_expensive_function():...my_expensive_function.cache.invalidate()Cache a view (only synchronous updates).# cached_functions.pyfromupdate_cache.decoratorsimportcache_view@cache_view()defmy_expensive_view():...View all cached entries in Django Admin:
Package: django-update-from-dict
Installation$[sudo]pipinstalldjango-update-from-dictExamplesMixin:fromdjango.dbimportmodelsfromdjango_update_from_dictimportupdate_from_dict,UpdateFromDictMixinclassClassName(UpdateFromDictMixin,models.Model):...instance=ClassName()instance.update_from_dict(attrs,commit=True)function:fromdjango_update_from_dictimportupdate_from_dictupdate_from_dict(instance,attrs,commit=True)readme42.com
Package: django-updater
django-updaterDisplays a warning message in the admin when the used Django version is insecure or outdated and
provides a management command (or celery task) that checks for updates periodically.DocumentationThe full documentation is athttps://django-updater.readthedocs.org.QuickstartInstall django-updater:pip install django-updaterThen, add it to yourINSTALLED_APPS:INSTALLED_APPS = (
    ...
    "updater",
)If you want to enable it in the admin area, make sure to putupdaterbeforedjango.contrib.admin:INSTALLED_APPS = (
    ...
    "updater",
    "django.contrib.admin",
)UsageIf you have django-updater enabled in the admin area, it will display a info/warning message when
there are updates available automatically.In order to check for updates in an automated fashion, django-updater has to be called periodically. There are two ways to accomplish that:Running a periodicCelerytaskCreate a cronjobCeleryIf you are usingCeleryand have a celery beat daemon running, enable Celery support in your settings with:from datetime import timedelta

CELERYBEAT_SCHEDULE = {
    'run-django-updater': {
        'task': 'updater.tasks.run_check',
        'schedule': timedelta(days=1),
    },
}And you are good to go!CronjobYou can use a cronjob to check for updates once a day.To set up a cronjob, run:crontab -eAnd then add:30 2 * * * python /path/to/your/apps/manage.py check_for_updatesIf you are using a virtual environment, you might need to point to the python executable your virtual environment is using:30 2 * * * /path/to/virtual/environment/bin/python /path/to/your/apps/manage.py check_for_updatesScreenshotsHistory0.3.3 (2015-10-23)Added a lot of testsSimplified management commandsSome small refactorings0.4.0 (2015-10-25)Now compatible with Django 1.4 - 1.90.3.2 (2015-10-13)Fixed an error with squashed migrations0.3.1 (2015-10-13)Squashed migrations0.3.0 (2015-09-24)Added registration view0.2.2 (2015-09-24)Refactored modelsAdded admin pageReworked registration process0.2.1 (2015-09-14)Added callback token0.2.0 (2015-09-09)Major refactoring0.1.8 (2015-09-08)Fixed small typo0.1.7 (2015-09-08)Added notification serviceAdded inline documentationSmall refactorings0.1.6 (2015-09-07)Added online service registrationFixed minor issues0.1.5 (2015-08-19)Fixed minor issues0.1.4 (2015-08-19)Fixed packaging issue0.1.3 (2015-08-19)Temporarily fixing piprot issue with pytz0.1.2 (2015-08-19)Added package requirements0.1.1 (2015-08-19)Switched topip.get_installed_distributionsto get a package listminor documentation tweaks0.1.0 (2015-08-19)First release on PyPI.
Package: django-update-sql
Installation$[sudo]pipinstalldjango-update-sqlExamplesfromdjango_update_sqlimportupdate_sqlqs=Table.objects.filter(pk=42)kwargs=dict(key='value',updated_at=datetime.now())update_sql(qs,**kwargs)UPDATE"table"SET"key"='value',"updated_at"='2020-01-23T00:49:39'::timestampWHERE"id"=42readme42.com
Package: django-updown-ratings
django-updown-ratingsSimple Django application for adding Youtube like up and down voting.Thisdjango-updown-ratingsis forked fromdjango-updownto support the newest django version.Installpip install django-updown-ratingsUsageAdd"updown"to yourINSTALLED_APPS. Then just add aRatingFieldto your existing model:from django.db import models
from updown.fields import RatingField

class Post(models.Model):
    # ...other fields...
    rating = RatingField()You can also allow the user to change his vote:class Post(models.Model):
    # ...other fields...
    rating = RatingField(can_change_vote=True)Now you can write your own view to submit ratings or use the predefined:from updown.views import AddRatingFromModel

urlpatterns = [
    ....

    path('<int:object_id>/rate/<str:score>', AddRatingFromModel(), {
        'app_label': 'blogapp',
        'model': 'Post',
        'field_name': 'rating'
    }, name='post_rating'),
]To submit a vote just go topost/<id>/rate/(1|-1). If you allowed users to
change they're vote, they can do it with the same url.
Package: django-uploader
***************Django Uploader***************What it does============Django Uploader uses `jQuery file upload`_ to allow drag-and-drop file upload of any file type in the Django Admin. Third-party applications to write handlers for specific file types, and register them with Django Uploader. When a file of that type is uploaded, it passes the information to the handler so that it can make a new record with that file... _jQuery file upload: https://blueimp.github.io/jQuery-File-Upload/Installation============1. Installation is easy using ``pip``::pip install django-uploader2. Add ``uploader`` to your ``INSTALLED_APPS`` setting.3. Add the uploader's urls::url(r'^upload/', include('uploader.urls')),4. Write one or more upload handlers.5. Go to /admin/uploader/upload/ to start uploading.Writing an upload handler=========================.. note:: An upload handler does not have to exist within the application for which it creates records. It must simply be within an application that is imported so the handler can be discovered.An upload handler assigns one or more MIME types to a function. There should only be one handler for a given MIME type, although Uploader does allow some overlap using '\*'. For example, you can have one handler that handles ``image/tiff`` and another that handles ``image/*`` and yet another that handles ``*/*``\ . The ``image/tiff`` handler would get any ``.tiff`` images, the ``image/*`` would get any other type of image and the ``*/*`` handler would get any other type of file.To start, create a file named ``upload.py`` in your application. This file can contain several different handlers. When the Uploader application is first loaded, it attempts to import this file from every installed application.A basic handler looks like this::from uploader.registration import upload_handlersdef photo_handler(obj):"""Handle the creation of a SimpleModel record from an uploaded image."""from .models import SimpleModelnew_item = SimpleModel.objects.create(name=obj.filename,slug=obj.filename_slug,description='',file=obj.file_contents)return new_itemphoto_handler.thumbnail_attribute = 'thumb'upload_handlers.register(['image/jpeg', 'image/png'], photo_handler)
Package: django-upload-path
IntroductionThis application provides various implementations for theFileField/ImageField.upload_toattribute (https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to) (upload_toattribute accepts callable).These implementations are:auto_cleaned_pathwill generate{MODEL_NAME}/{SAFE_UPLOADED_FILENAME}{SUFFIX}auto_cleaned_path_uuid4will generate{MODEL_NAME}/{SAFE_UPLOADED_FILENAME}{SEPARATOR}{UUID4}{SUFFIX}auto_cleaned_path_stripped_uuid4will generate{MODEL_NAME}/{UUID4}{SUFFIX}ExampleFor example, howauto_cleaned_pathworks: First, the original file name (typically from the user) is always cleaned (usingdjango.utils.text.slugify). Then, a new path is generated that contains the model name.If you have aMyModelmodel and the user uploads afoo-bar.txtfile, the resulting path will bemymodel/foo-bar.txt.fromdjango.dbimportmodelsfromdjango_upload_pathimportauto_cleaned_pathclassMyModel(models.Model):file=models.FileField(upload_to=auto_cleaned_path)InstallationSupported Python versions are:3.4.,3.5,3.6and3.7-dev.Supported Django versions are:1.8.x(LTS),1.9.x,1.10.xand1.11.x(LTS).pipinstalldjango-upload-pathDo notadd the app toINSTALLED_APPS(it is useless).Usagefromdjango.dbimportmodelsfromdjango_upload_path.upload_pathimportauto_cleaned_path,auto_cleaned_path_stripped_uuid4,auto_cleaned_path_uuid4classMyModel(models.Model):file1=models.FileField(upload_to=auto_cleaned_path)file2=models.FileField(upload_to=auto_cleaned_path_stripped_uuid4)file3=models.FileField(upload_to=auto_cleaned_path_uuid4)Note:ImageField(https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ImageField) is also supported.LicenseThe MIT License (MIT)Copyright (c) 2017 Vašek Dohnal (@illagrenan)Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
“Software”), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package: django-uploads-app
Django uploads managerDocumentationThe full documentation is athttps://django-uploads-app.readthedocs.io.QuickstartInstall Django Uploads App:pip install django-uploads-appAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'django_uploads_app.apps.DjangoUploadsAppConfig',...)Add Django Uploads App’s URL patterns:fromdjango_uploads_appimporturlsasdjango_uploads_app_urlsurlpatterns=[...url(r'^',include(django_uploads_app_urls)),...]FeaturesTODORunning TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxDevelopment commandspip install -r requirements_dev.txt
invoke -lCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.8.0 (2021-10-11)First release on PyPI.
Package: django-uploadstatic
This is a Django app that provides helpers for uploading static files.It is based off ofgithub.com/jezdez/django-staticfilesbut only uploads all the files in the collectedSTATIC_ROOTto S3 using
thestorages.backends.s3boto.S3BotoStoragestorage backend in thedjango-storagesapp.InstallationUse your favorite Python packaging tool to installuploadstaticfromPyPI, e.g.:pip install django-uploadstaticAdded"uploadstatic"to yourINSTALLED_APPSsetting:INSTALLED_APPS = [
    # ...
    "uploadstatic",
]Set yourSTATIC_URLsetting to the URL that handles serving
static files from S3:STATIC_URL = "https://s3.amazonaws.com/some-domain/"Once you are ready to upload all static files that have been collecte in your
site’sSTATIC_ROOT, use theuploadstaticmanagement
command:python manage.py uploadstaticThen your files will be accessible from theSTATIC_URLsetting.
Package: django-upload-to
django-upload-toIt generates dynamically a directory path and a secure file name for Django FileField.Main options:Ready to use generators.Generate secure file name without especial characters.Generate file name using a uuid value.Dynamically generate paths from the model instance.Generate paths using Python datetime formats.Get startedInstall the django-upload-to in your virtual environment$pipinstalldjango-upload-toImport it in your models file and add it as aupload_toargument in theFileField# my_app/models.pyfromupload_toimportUploadTofromdjango.dbimportmodelsclassMyModel(models.Model):attachment=models.FileField(upload_to=UploadTo("attachments"))The path and file name generated will be like this:"attachments/the-file-name-uploaded.pdf"How to use the ready-to-use classesConsider the scenario below:importupload_tofromdjango.dbimportmodelsclassMyUser(models.Model):username=models.CharField(...)avatar=models.FileField(upload_to=<generator>)instance=MyUser(username='user@email.com')Replace the<generator>fragment by the generators as showed below:File in root folder>>>generator=upload_to.UploadTo()>>>generator(instance,"file.pdf")"file.pdf"Define a folder structure>>>generator=upload_to.UploadTo(prefix=["files","documents"])>>>generator(instance,"file.pdf")"files/documents/file.pdf"Generate a folder name using datetime formats from Python>>>generator=upload_to.UploadTo(prefix=["pictures","%Y"])>>>generator(instance,"file.png")"pictures/2023/file.png"Replace the file name by an hexadecimal uuid value# 4. replace file name by a uuid value>>>generator=upload_to.UuidUploadTo()>>>generator(instance,"file.pdf")"b189dfdf25e640b2ba5c497472c20962.pdf"Generate the folder path using the instance's attributes>>>generator=upload_to.AttrUploadTo(attrs=["username"])>>>generator(instance,"file.pdf")"useremailcom/file.pdf"Generate the folder path using the app_label and the model_name from the instance's meta options>>>generator=upload_to.ModelUploadTo()>>>generator(instance,"file.pdf")"my_app/user/file.pdf"Customize your upload paths# my_app/models.pyimportupload_tofromdjango.dbimportmodelsdefmy_upload_generator(instance,filename):filename=upload_to.uuid_filename(filename)path=upload_to.options_from_instance(instance)returnupload_to.upload_to(path,filename)classMyProfile(models.Model):user=models.OneToOneField(...)avatar=models.FileField(upload_to=my_upload_generator)Useful linksDocumentationChangelogPyPi Page
Package: django-upload-validator
Django Upload Validator is a simple utility for validating file types and extensions usingpython-magiclibrary.InstallationInstall thecurrent PyPI release:pipinstalldjango-upload-validatorUsageGeneral usagefrom upload_validator import FileTypeValidator

validator = FileTypeValidator(
    allowed_types=['application/msword'],
    allowed_extensions=['.doc', '.docx']
)

file_resource = open('sample.doc')

# ValidationError will be raised in case of invalid type or extension
validator(file_resource)Usage as a FileField validator in Django formsfrom upload_validator import FileTypeValidator

 profile_image = forms.FileField(
    label='', help_text="Formats accepted: JPEG nd PNG", required=False,
    validators=[FileTypeValidator(
        allowed_types=[ 'image/jpeg','image/png']
    )]
)Wildcard character specification is also supported. e.g; for accepting only images:profile_image = forms.FileField(
    label='', help_text="Only image formats are accepted.", required=False,
    validators=[FileTypeValidator(
        allowed_types=[ 'image/*']
    )]
)Running TestsInstall testing requirementspip install -r tests/requirements.txtRunpython runtests.pyinside the root directory of package
Package: django-ups-tnt
# Django UPS Time In Transitdjango-ups-tnt is a wrapper around UPS's Time In Transit (TNT) API.This wrapper is necessary because UPS's API is not public and requires Authentication details that cannot be sharedin javascript.It provides some defaults to make the api easier to work with.It also provides some form validation before hitting the UPS API and cache# InstallationRequires djangorestframework>=3.3.0. Tested on Django 1.8 and 1.9.1. Add `django-ups-tnt` to requirements.txt or pip install.2. Add `url(r'^api/', include('ups_tnt.urls')),` to urls.py3. Set required settings in settings.py## Settings### RequiredUPS_USERNAMEUPS_PASSWORDUPS_ACCESS_LICENSE_NUMBER### Override defaultsUPS_DEFAULT_SHIP_FROMUPS_DEFAULT_SHIP_TODefault shipping addressesExample syntax:```{"Address": {"CountryCode": "US",}}```UPS_BUFFER_DAYS - add buffer to when the item is shipped. Defaults to 0. Set to a int or callable.UPS_DEFAULT_SHIPMENT_WEIGHT - Set shipment weight. Example```UPS_DEFAULT_SHIPMENT_WEIGHT = {"UnitOfMeasurement": {"Code": "LBS","Description": "Pounds"},"Weight": "90"}```UPS_DEFAULT_INVOICE - Set value of shipment```UPS_DEFAULT_INVOICE = {"CurrencyCode": "USD","MonetaryValue": "800"}```UPS_TEST_LIVE - Set to `True` to make unit tests access actual API instead of mocksUPS_CACHE_NAME - Set to the name of the cache to use. Defaults to `default`
Package: django-upstorage-backend
django-upstorage-backendThis is a custom django storage backend forUpStorageInstallationInstall Library Usingpip>>pipinstalldjango-upstorage-backendStarting GuideSet The Custom Storage Backend. Now Open settings.py of your project.DEFAULT_FILE_STORAGE='django-upstorage-backend.storages.backends.U3Storage'Set some required KEYS tosettings.pyAUTH_TOKEN='auth token from your account'API_KEY='api key of your project'USERNAME='username of your account'PROJECT_NAME='Created Project name'Thats it, We are all done. Now all of your files will be handeled by the custom UpStorage's Backend Storage.Advanced GuideYou don't need to set 'upload_to' in model Fields (Defaultly it files will be saved on the root of your project.)File Link Will Be Stored On Your Model As Expected.You Can call them as you do usally.You Can also set 'upload_to='specific/folder' in your model like:ClassTestModel(model.Model):image=models.ImageField(upload_to='to/my/folder')# this will save the file to that folder.if there's no folder it will create it.If you want to delete the image from the UpStorage Bucket when you delete it from django, you have to do it a bit differently.Lemme show youClassTestModel(model.Model):image=models.ImageField()# To delete the image you have to delete that by writing:obj=TestModel.objects.get(id=pk)obj.image.delete()# You can't directly delete it like this:obj.delete()# this won't delete the file from UpStorage# You have to delete the file field first to delete it.To make it simple you can overridedeleteMethod on your ModelClassTestModel(model.Model):image=models.ImageField()defdelete(self):self.image.delete()super(TestModel,self).delete()
Package: django-uptime
django-uptimeEditable non-cached monitorization path for DjangoInstallationTo installdjango_uptimesimply run:pipinstalldjango-uptimeConfigurationWe need to hookdjango-uptimeinto our project.Putdjango_uptimeinto yourINSTALLED_APPSat settings module:INSTALLED_APPS=(# other apps"django_uptime",)Include the desired url path into your projects mainurls.pyfile:fromdjango.urlsimportinclude,pathurlpatterns=[...path('ok/',include('django_uptime.urls')),...]