Saravanan666/pypi-org huggingface dataset:
Package: django_soft_atomic
django-soft-atomicA more forgiving variation ofdjango'satomic, allowing you to pass some
exceptions through atomic block without rollback.RationaleIn big applications you may end up relying on exceptions mechanism to pass information
about failure up the stack. Unfortunately, if your business logic involves operations on
database, there is no easy way to wind up execution through atomic block without
rolling back entire transaction.django-soft-atomictries to solves this problem
by allowing certain exceptions to exit atomic block just like sucessful execution
(still maintaining the raised exception).RequirementsPython 3.6+Django 3.2+InstallationWith PIPExecute:pip install django_soft_atomicSee also:PyPI PageManualCopydjango_soft_atomic.pyto your codebase and simply start using it.Usage (docs)This "package" constists of single decorator/context-manager, acting as replacement for django'satomic:soft_atomic(using=None, savepoint=True, durable=False, *, safe_exceptions=(Exception,))using- database name to use
(same as original atomic),savepoint- disable usage of savepoints in inner blocks
(same as original atomic),durable- ensure this is outermost block
(same as original atomic),safe_exceptions- collection (e.g.tuple) of exceptions which are allowed to pass throughsoft_atomicblock without rollback. Typical DB errors (likeIntegrityError) will still throw. Defaults to:(Exception,).ExampleLet's take a simple example, where we would like to perform payment operation and raise an exception if it fails.
We want to create a database entry for both outcomes.fromdjango_soft_atomicimportsoft_atomicclassPaymentProcessingException(Exception):passclassPaymentRequest(models.Model):payment_id=models.TextField()success=models.BooleanField()@soft_atomic(safe_exceptions=(PaymentProcessingException,))defprocess_payment(payment_details):payment_id,success=payment_gateway.process_payment(payment_details)PaymentRequest.objects.create(payment_id=payment_id,success=success)ifnotsuccess:raisePaymentProcessingException("Payment was not sucessful")defpayment_endpoint(payment_details):try:process_payment(payment_details)exceptPaymentProcessingException:...# handle a failureelse:...# payment was successful# in either case the `PaymentRequest` record was created in the database
Package: django-soft-delete
Django Soft DeleteThis is a set of small classes to make soft deletion of objects.Use the abstract modelSoftDeleteModelfor adding two new fields:is_deleted- is a boolean field, shows weather of a deletion state of objectdeleted_at- is a DateTimeField, serves a timestamp of deletion.Also, you can useSoftDeleteManagerandDeletedManagerobject managers for getting
alive and deleted objects accordingly.By default, theSoftDeleteModelhasobjectsattribute asSoftDeleteManageranddeleted_objectsattribute asDeletedManager.How to usepip install django-soft-deleteAdd theSoftDeleteModelas a parent for your model:# For regular modelfromdjango.dbimportmodelsfromdjango_softdelete.modelsimportSoftDeleteModelclassArticle(SoftDeleteModel):title=models.CharField(max_length=100)# Following fields will be added automatically# is_deleted# deleted_at# Following managers will be added automatically# objects = SoftDeleteManager()# deleted_objects = DeletedManager()# global_objects = GlobalManager()# For inherited modelfromdjango_softdelete.modelsimportSoftDeleteModelclassPost(SoftDeleteModel,SomeParentModelClass):title=models.CharField(max_length=100)Make and apply the migrations:./manage.py makemigrations
./manage.py migrateRelationsYou can also use soft deletion for models that are related to others. This library does not interfere with standard Django functionality. This means that you can also use cascading delete, but remember that soft delete only works with theSoftDeleteModelclasses. If you delete an instance of the parent model and use cascading delete, then the instances of the child model will be hard-deleted. To prevent hard deletion in this case, you should useSoftDeleteModelfor child models in the same way as for parent model.Quick examplea1=Article.objects.create(title='django')a2=Article.objects.create(title='python')a3=Article.objects.create(title='django_softdelete')Article.objects.count()# 3a1.delete()# soft deletion of objectArticle.objects.count()# 2deleted_a1=Article.deleted_objects.first()# <Article: 'django'>deleted_a1.restore()# restores deleted objectArticle.objects.count()# 3Article.deleted_objects.count()# 0a1.hard_delete()# deletes the object at all.Batch deletionArticle.objects.filter(some_value=True).delete()# soft delete for all filtered objectsArticle.deleted_objects.filter(some_value=True).restore()# restore for all filtered objectsCustom managerIf you need a soft delete functionality for model with your own object manager,
you want to extend it with theSoftDeleteManager.fromdjango_softdelete.modelsimportSoftDeleteManagerclassYourOwnManager(SoftDeleteManager):passThe same class exists for thedeleted_objectsmanager too --DeletedManager.Custom QuerySetIf you need to use soft delete functionality for your customQuerySet, use theSoftDeleteQuerySetas a parent class or extending existing one.fromdjango_softdelete.modelsimportSoftDeleteQuerySetclassYourOwnQuerySet(SoftDeleteQuerySet):pass
Package: django-softdelete-new
Django-softdelete-new基于Django的轻量级软删除插件，支持Django>=1.11。快速开始1、安装插件pipinstalldjango-softdelete-new2、导入基本Modelfromsoft_delete_new.modelsimportSoftDeleteModel3、将SoftDeleteModel类继承到模型类。它将添加以下功能：​objects的行为将发生以下变化：​		返回所有非软删除的数据对象​		delete() 方法将变成软删除方法。​		hard_delete() 增加的方法，将数据真正从数据库中删除。​all_objects是新增加的行为：​		将始终返回软删除和非软删除的对象​		only_deleted() 仅返回软删除对象的方法​		undelete() 可以将all_objects返回的已经软删除的对象置为非软删除。实例fromdjango.dbimportmodelsfromsoft_delete_it.modelsimportSoftDeleteModelclassAuthor(SoftDeleteModel):name=models.CharField(max_length=50)dob=models.DateField()classArticle(SoftDeleteModel):title=models.CharField(max_length=50)body=models.TextField(null=True)author=models.ForeignKey(Author,on_delete=models.CASCADE,related_name='articles')Bob=Author.objects.create(name='bob',dob='2000-12-12')John=Author.objects.create(name='john',dob='1990-10-12')Author.objects.all()# return QuerySet with 2 objectsBob.delete()# Bob is soft-deletedAuthor.objects.all()# return QuerySet with 1 object, JohnAuthor.all_objects.all()# return QuerySet with 2 object, Bob and JohnBob.undelete()# un-deletes Bob objectAuthor.objects.all()# return QuerySet with 2 objectsarticle1=Article(title='Bob The Builder',body='')article1.author=Bobarticle1.save()Article.objects.all()# return QuerySet with 1 object, article1Bob.delete()# soft-deletes both Bob and article1 as Article's author field is on_delete_cascade and it Inherits SoftDeleteModel
Package: django-softdeletion
django softdeletion基于 django 的软删除插件主要功能支持软删除支持级联软删除软删除的数据不在 django admin 中显示安装pip install django-softdeletion使用方法from django.db import models
from django_softdeletion import SoftDeletionModelMixin


class CustomModel(SoftDeletionModelMixin, models.Model):
    ...
Package: django-softlayer
Django storage for SoftLayer Cloud StorageThis package uses django-cumulus (https://pypi.python.org/pypi/django-cumulus) and
softlayer-object-storage-python (https://pypi.python.org/pypi/softlayer-object-storage).Link to github repository:https://github.com/Arpaso/django-softlayerSettingsAdd the following to your project’ssettings.py(your SoftLayer credentials):CUMULUS = {
    'USERNAME': 'YourUsername', # your SoftLayer user name
    'API_KEY': 'YourAPIKey',    # SoftLayer api key
    'CONTAINER': 'ContainerName' # SoftLayer container(folder) name
    'NETWORK': 'private', # Paid 'private' or free 'public' network is available
}

CLOUD_FILE_STORAGE = 'django_softlayer.SoftLayerStorage'
INSTALLED_APPS = [
    ...
    'django_softlayer',
    ...
]UsageTo use this storage:import storage class, and create your own storage.py:from django_softlayer import SoftLayerStorage
from django.utils.functional import LazyObject
from django.conf import settings

class MyStorage(LazyObject):
    def _setup(self):
        self._wrapped = get_storage_class(settings.CLOUD_FILE_STORAGE)()Then you can use it in models.py:from storage import MyStorage

class MyModel(Model):
    file = models.FileField(storage=MyStorage())That’s all.To upload files to storage from folder, check for the command usage:./manage.py syncstatic --helpTestingTo run tests:./manage.py test django_softlayerManagement commandssyncstaticUploads directories to the cloud storage saving directory structure:python manage.py syncstaticOptions–mediaroot- A source directory to copy files from, e.g. “/home/djangoprojects/myproject/media”.Defaults to settings.MEDIA_ROOT.–noreplace- Skip and do not replace existing files in the storage.Default is False.–mask- A file mask, e.g.*.ext.Defaults to: *.mp3-v- higher verbosity is availableget_missing_filesPrints information to console about empty or non existing files present in database but not at cloud files storage:python manage.py get_missing_filesOptions–app_model_field- String containing dot separated app, model and field name.Example: myapp.User.fileNOTE:this options can be defaulted toCMD_MISSING_FILES_SETTINGSvariable insettings.py:CMD_MISSING_FILES_SETTINGS = (
    'app.model.filefield',
    'nextapp.nextmodel.nextfile'
)WhenCMD_MISSING_FILES_SETTINGSvariable is in settings.py, you can search a set ofapp.model.fieldto search for empty files.When using–app_model_fieldoption, you can only specify oneapp.model.fieldper command.Written by the development team of Arpaso company:http://arpaso.com
Package: django-softmachine
Django-Softmachine proposes an approach based on DATARUN method.
This approach consists in achieving the interfaces of an application by the contruction of views from a normalized data model.In other words, you can prototype and export a new application model.
The system architecture is a Web MVC variant, this means that we use the basic concepts of Model, View and Controller adapted to a Meta-Data Driven Web App.Documentation:http://certae.github.io/django-softmachine/Source and install guide:https://github.com/certae/django-softmachineMain screen example:Page edited with online reStructuredText editor:http://rst.ninjs.org/
Package: django-soft-remover
django-soft-removerAbstract Django models for soft removal.It supports unique field indices specified withuniqueunique_togetherUniqueConstraint(without expressions or conditions)Just add theremverfield to the composite unique index if you need to maintain uniqueness between removed versions.Installation$pipinstalldjango-soft-removerExample of usefromdjango.dbimportmodelsfromsoft_remover.modelsimportSoftRemovableModel,SoftRestorableModelclassManyUniqueTogetherRem(SoftRemovableModel):category=models.CharField(max_length=32)name=models.CharField(max_length=32)tag=models.CharField(max_length=32)value=models.PositiveSmallIntegerField()classMeta:unique_together=(('category','name','remver'),('category','tag','remver'))classUniqueWithConstraint(SoftRemovableModel):name=models.CharField(max_length=32)classMeta:constraints=[models.UniqueConstraint(fields=['name','remver'],name='uwc_name_remver'),]classManyUniqueTogetherRes(SoftRestorableModel):category=models.CharField(max_length=32)name=models.CharField(max_length=32)tag=models.CharField(max_length=32)value=models.PositiveSmallIntegerField()classMeta:unique_together=(('category','name'),('category','tag'))See more examples intest models.LicenseMIT
Package: django-soil
This is a simple app to help you schedule long running tasks for retrieval later when they’re done.
Two modes of operation:  1:  sit and refresh page till it’s done with a download link, or 2: send a “done” email with a link to a page with the resulting download.If you want to server large binaries over a cache, you must have django-redis installed, otherwise python-memcached is all you needThere are a few settings you can use to tweak the default cache storage:SOIL_DEFAULT_CACHE = ‘soil.FileDownload’ # or ‘soil.CachedDownload’
SOIL_DEFAULT_CACHE = ‘default’           # or ‘memcached’, ‘redis’, etc.
Package: django-solarnext
Polls is a Django app to conduct Web-based polls. For each question,
visitors can choose between a fixed number of answers.Detailed documentation is in the “docs” directory.Quick startAdd “polls” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'polls',
]Include the polls URLconf in your project urls.py like this:path('polls/', include('polls.urls')),Runpython manage.py migrateto create the polls models.Start the development server and visithttp://127.0.0.1:8000/admin/to create a poll (you’ll need the Admin app enabled).Visithttp://127.0.0.1:8000/polls/to participate in the poll.
Package: django-solominh-polls
Polls is a simple Django app to conduct Web-based polls. For each
question, visitors can choose between a fixed number of answers.Detailed documentation is in the “docs” directory.Quick startAdd “polls” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'polls',
]Include the polls URLconf in your project urls.py like this:url(r'^polls/', include('polls.urls')),Runpython manage.py migrateto create the polls models.Start the development server and visithttp://127.0.0.1:8000/admin/to create a poll (you’ll need the Admin app enabled).Visithttp://127.0.0.1:8000/polls/to participate in the poll.
Package: django-sorl-hacks
create_thumbs template tagParse your text on fly, finds images urls and replace it by thumb url:{% load sorl_hacks %}

{% for text_block in post.blocks.all %}
    <h4>{{ text_block }}</h4>
    <p>{{ text_block.body|create_thumbs|safe }}</p>
    <hr>
{% endfor %}ThumbedCkeditorImagesAdmin model mixin with post_save replacing.admin.py:fromsorl_hacks.adminimportThumbedCkeditorImagesclassBlogPostAdmin(ThumbedCkeditorImages):...ThumbMixinUsefull in stadart Django templates. Add propertymy_model.get_thumb_WIDTHxHEIGHTto yours models.Example ofmy_model_detail.html:{{ my_model.get_thumb_200x200.html }}

{{ my_model.get_thumb_small.html }}instead of:{% thumbnail my_model.pic "56x56" crop="center" as im %}
    <img src="{{ im.url }}" width="56" height="56">
{% empty %}
    <img src="{{ MISSING_IMAGE }}" width="56" height="56">
{% endthumbnail %}INSTALLYourmodels.py:fromdjango.dbimportmodelsfromsorl.thumbnailimportImageFieldfromsorl_hacks.modelsimportThumbMixinclassPost(ThumbMixin,models.Model):image=ImageField('image',upload_to='posts',**nullable)
Package: django-sortable-column
=====Sortable Column=====Sortable Column is a simple Django templatetag to renders a sortable column tosupport sorting in tables.Detailed documentation on GitHub (https://github.com/weynelucas/django-sortable-column)Quick start-----------1. Add "sortable_column" to your INSTALLED_APPS setting like this:INSTALLED_APPS = [...'sortable_column',]2. Include the following snippet at the top of any template that makes use ofthe sortable column tags:{% load sortable_column %}3. Use sortable_column tag on your template to render th tags for support the sortingin tables:{% sortable_column request=request property="title" title="Title" %}4. Handle 'sort' and 'order' parameters generated by sortable_column tag in your view functionfor sorting your dataset.
Package: django-sortable-listview
django-sortable-listviewAn extension of django's ListView that provides sorting.Features:Works with django's built in pagination.Contains templates & css for pagination and sort buttons (or just use the context_data and build your own).Adds an arrow to show the sort direction on the active sort.Knows what the next sort is (i.e. if you're already sorted by title in one direction, clicking on the title button/link again will sort it in the other direction).Lets you specify default sort for your list (defaults to -id) and for each of the sortable fields.Modifies the queryset, so your database does your sorting.Maintains additional query strings (configurable)RequirementsThese are the supported versions. Older versions may also work.* Python (2.7, 3.5, 3.6, 3.7)
* Django (1.11, 2.1, 2.2)InstallUsing pip::pip install django-sortable-listviewIf you want to use the provided templates and CSS add'sortable_listview'to your INSTALLED_APPS in your django settings.To see how to include the css and templates in your application, look at the example project. The css is just standard bootstrap.Example ProjectTo run the example project. First make sure django and django-sortable-listview are on your python path. For example, from inside a virtualenv::pip install django
pip install django-sortable-listviewThen from your cloned folder::cd example_project
python manage.py migrate
python manage.py runserverYou should be able to see the example project at localhost:8000. A database is provided with some sample content. The username and password is admin/adminDevelopment and TestsFor your development setup::pip install -r requirements-dev.txtTo run the tests::toxYou may not want to run the whole tox suite when you are doing development.
In this case, uncomment the extra lines in requirements-dev.txt, but please
don't commit these changes. (Suggestions welcome on a better way to manage this)Change Log0.43Fix for Python 3 regression for params to remove (thanks @bw-aus, @ghost, @birdsarah)Update tox to use Django 2.2 (thanks @birdsarah)0.42Fix for Django 1.11Fix encoding problem (thanks @bw-aus)Add CSS classes to template (thanks @JanMalte)Fix missing translation (thanks @JanMalte and @valentjedi)Preserve ordering of allowed sort fields (thanks @tooreht)0.41Further querystring improvement (thanks @fle)Test against Django 1.80.40Add support for Python 3Add tox & travis to test all variationsUpdate license to MIT0.30Add support for preserving other query strings (thanks @fle)Make sure tests run in 1.6 and 1.7 (thanks @fle)
Package: django-sortedm2m-filter-horizontal-widget
django-sortedm2m-filter-horizontal-widgetsortedm2m-filter-horizontal-widgetis an admin widget for Gregor
Mülleggers excellentdjango-sortedm2mlibrary.This allows for a familiar filter horizontal widget.Installationpip install django-sortedm2m-filter-horizontal-widgetWhat version do I need?DjangoInstall< 1.80.21.81.1>= 1.91.2.1>= 2.01.3.2>= 3.0latestUsageAddsortedm2m_filter_horizontal_widgetto yourINSTALLED_APPS(needed for static files).In yourModelAdminadd the following function to override the default
widget. :from sortedm2m_filter_horizontal_widget.forms import SortedFilteredSelectMultiple

class MyModelAdmin(admin.ModelAdmin):
    # ...

    def formfield_for_manytomany(self, db_field, request=None, **kwargs):
        if db_field.name == 'your_sortedm2m_field_name':
            kwargs['widget'] = SortedFilteredSelectMultiple()
        return super(MyModelAdmin, self).formfield_for_manytomany(db_field, request, **kwargs)TodoAutomatically assign widget if field is specified in ModelAdmin'sfilter_horizontal.Add tests
Package: django-sortedmanytomany
django-sortedmanytomany=======================> In Django, if you need to order a many to many relation you will have to do it by using inlines width a foreign key and a sorting field. If there is no need to add another field in this relation, use inlines would make the admin interface complex where a simple many to many should do the trick.Installation------------```shpip install django-sortedmanytomany```Adding to installed apps------------------------- To use the many to many sorted field, you have to add it to your INSTALLED_APPS on your project's settings.py so the needed static files can be loaded:```pythonINSTALLED_APPS = (...'sortedmanytomany',)```Using SortedManyToManyField---------------------------- To use SortedManyToMany field, just create a field as if you were adding the default ManyToMany```pythonfrom django.db import modelsfrom sortedmanytomany.models import SortedManyToManyFieldclass Album(models.Model):...tracks = SortedManyToManyField('Track')class Track(models.Model):...```License-------MIT
Package: django-sorter
django-sorterhelps with sorting objects in Django templates without
modifying your views, can be used multiple times on the same page or
template, provides helpers to easily generate links and forms to switch
the sorting criteria (including the sort order) and has ~100% test coverage.QuickstartGet the app with your favorte Python packaging tool, e.g.:pip install django-sorterList this application in theINSTALLED_APPSsetting.
Your settings file might look something like:INSTALLED_APPS = (
    # ...
    'sorter',
)If it’s not already added in your setup, add therequesttemplate
context processor to theTEMPLATE_CONTEXT_PROCESSORSsetting
(you might need toadd it):TEMPLATE_CONTEXT_PROCESSORS = (
    # ...
    'django.core.context_processors.request',
)Specify the allowed sorting criteria, for at least the default'sort'sorting querystring parameter:SORTER_ALLOWED_CRITERIA = {
    'sort': ['first_name', 'creation_date', 'title'],
}Add this line at the top of your template to load the sorting tags:{% load sorter_tags %}Decide on a variable that you would like to sort, and use the
sort tag on that variable before iterating over it.{% sort objects as sorted_objects %}Optionally, you can display different sort links or forms:<tr>
   <th>{% sortlink by "first_name" %}By first name{% endsortlink %}</th>
   <th>{% sortlink by "creation_date,-title" %}By creation date and title{% endsortlink %}</th>
    ...
</tr>The template tag takes a comma separated list of sorting statements.
It also is a block tag and allows you to set the label of the generated
link. The previous snippet will be rendered like this:<tr>
    <th><a href="/?sort=first_name" title="Sort by 'first_name' (asc)">By name</a></th>
    <th><a href="/?sort=creation_date,-title" title="Sort by 'creation_date' (asc) and 'title' (desc)">By creation and title</a></th>
    ...
</tr>Similarly the{% sortform %}template tag renders a form instead of
a simple link.
Package: django-sorting
How to use django-sorting----------------------------``django-sorting`` allows for easy sorting, and tables headers (<th>) generationwithout modifying your views.There are really 5 steps to setting it up with your projects.1. List this application in the ``INSTALLED_APPS`` portion of your settingsfile.  Your settings file might look something like::INSTALLED_APPS = (# ...'sorting',)2. Install the sorting middleware. Your settings file might look somethinglike::MIDDLEWARE_CLASSES = (# ...'sorting.middleware.SortingMiddleware',)3. If it's not already added in your setup, add the request context processor.Note that context processors are set by default implicitly, so to set themexplicitly, you need to copy and paste this code into your underthe value TEMPLATE_CONTEXT_PROCESSORS::("django.core.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.request")4. Add this line at the top of your template to load the sorting tags:{% load sorting_tags %}5. Decide on a variable that you would like to sort, and use theautosort tag on that variable before iterating over it.{% autosort object_list %}6. Now, you want to display different headers with links to sortyour objects_list:<tr>{% th first_name Name %}{% th creation_date Creation %}...</tr>The first argument is a field of the objects list, and the secondone(optional) is a title that would be displayed. The previoussnippet will be rendered like this:<tr><th><a href="?sort=first_name" title="Name">Name</a></th><th><a href="?sort=creation_date" title="Name">Creation</a></th>...</tr>That's it!