Saravanan666/pypi-org huggingface dataset:
Package: django-datatables-ajax
# Django Datatables server processingLightweight Django class for a full Datatables server processing implementation.https://datatables.net/examples/data_sources/server_side.htmlAfter hanging around for a good integration of Datatables server processing in Django, I tested the things I found on internet but they all have the same problem, they cannot manage the ForeignKey relations as well. After all, I made it by myself.This code was tested on Datatables 1.10.+ and Django 1.10.+.To get it works just put datatables in your html template, like this:```html<!-- jQuery --><script src="/statics/js/vendors/jquery/dist/jquery.min.js"></script><!-- Datatables --><script src="/statics/js/vendors/datatables.net/js/jquery.dataTables.js"></script><!-- Datatables --><script>$(document).ready(function() {$('.datatable-responsive-serverside').DataTable({"aLengthMenu": [[25, 50, 100, 500, ], // -1],[25, 50, 100, 500, ] //"All"]],"paging": true,"responsive": true,"processing": true,"serverSide": true,"ajax": "{% url 'appnamespace:viewname_json' %}",// POST METHOD EXAMPLE HERE//~ "ajax": {//~ url: "{% url 'appnamespace:viewname_json' %",//~ method: 'post',//~ data: function(args) {//~ return {//~ "args": JSON.stringify(args)//~ };//~ }//~ },});});</script>```Requirements------------Download your preferred DataTables release from [here](https://datatables.net/download/).Setup and examples------------------Install package in your Python environment.````pip install git+https://github.com/peppelinux/django-datatables-ajax.git````Create a view````from django.conf import settingsfrom django.contrib.auth.decorators import login_requiredfrom django.db.models import Qfrom django.http import HttpResponse, Http404from django.http.response import HttpResponseRedirectfrom django.http import JsonResponsefrom .datatables import DjangoDatatablesServerProc@login_requireddef datatable_data(request):radcheck = get_radcheck_active(request)radius_accounts = _get_radius_accounts(request, radcheck)model               = RadiusPostAuthcolumns             = ['pk', 'username', 'reply', 'calling_station_id', 'date']base_query = model.objects.filter(username__in=[i.username for i in radius_accounts]).exclude(calling_station_id='').order_by('-date')class DTD(DjangoDatatablesServerProc):def get_queryset(self):if self.search_key:self.aqs = base_query.filter(Q(username__icontains=self.search_key) | \Q(reply__icontains=self.search_key)    | \Q(calling_station_id__icontains=self.search_key))else:self.aqs = base_query.filter(username=radcheck.username)dtd = DTD( request, model, columns )return JsonResponse(dtd.get_dict())````Create an url resource````from django.conf.urls import include, urlfrom django.contrib.auth.decorators import login_requiredfrom .views import *urlpatterns = [url(r'^datatable.json$', login_required(StatoUtenzaCorso_DTJson), name='datatable_json'),]````
Package: django-datatablesform
DataTablesForm is a simple Django app for connecting the datatables 1.10 js plugin with a standard django ModelForm.Quick startAdd “datatablesform” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'datatablesform',
]Create a form inheriting from DataTablesForm:from datatablesform import forms
....
class MyModelForm(forms.DataTablesForm):
    list_display = ['field1', 'field2', 'fk_field__field', 'class_method_with_allow_tags"]

    class Meta:
        model = MyModel
        fields = '__all__'Use the previous form in any view:def my_form_view(request):
    ....
    form = MyModelForm()
    #_filters = {k,v for k,v in any_model_filter_wanted}
    #_exclude = {k,v for k,v in any_model_exclude_filter_wanted}
    script_table = form.factory_table() #form.factory_table(_filters, _exclude)
    table = 'MyModel'
    return render(request, "my_form_template.html", locals())Be aware of having the needed datatables static files in your “my_form_template”, also you’ll need to create a table element and include the script_table:<link href="your_static_dir" rel="stylesheet"/>
....
<table class="dataTable" id="table-{{table}}"></table>
....
<script src="your_static_dir">...</script>
....
{{script_table|safe}}You can always make an ajax request to retrieve the script or use the code to your best.
Package: django-datatables-too
Django DataTables TooAuthor:Tim Santortsantor@xstudios.agencyOverviewHandle server side processing for datatables 1.10.x.Getting ItTo install Django DataTables Too, just use pip:$ pip install django-datatables-tooUsageviews.pyfrom django.http import JsonResponse
from django.views.generic import View
from django_datatables_too.mixins import DataTableMixin

class DataTablesAjaxPagination(DataTableMixin, View):
    model = Report
    queryset = Report.objects.all()

    def _get_actions(self, obj):
        """Get action buttons w/links."""
        return f'<a href="{obj.get_update_url()}" title="Edit" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></a> <a data-title="{obj}" title="Delete" href="{obj.get_delete_url()}" class="btn btn-danger btn-xs btn-delete"><i class="fa fa-trash"></i></a>'

    def filter_queryset(self, qs):
        """Return the list of items for this view."""
        # If a search term, filter the query
        if self.search:
            return qs.filter(
                Q(number__icontains=self.search) |
                Q(title__icontains=self.search) |
                Q(state__icontains=self.search) |
                Q(year__icontains=self.search)
            )
        return qs

    def prepare_results(self, qs):
        # Create row data for datatables
        data = []
        for o in qs:
            data.append({
                'number': o.number,
                'title': Truncator(o.title).words(10),
                'state': o.state,
                'year': o.year,
                'published': o.published,
                'modified': o.modified,
                'actions': self._get_actions(o)
            })
        return data

    def get(self, request, *args, **kwargs):
        context_data = self.get_context_data(request)
        return JsonResponse(context_data)urls.pyfrom django.urls import path

from . import views

app_name = 'reports'

urlpatterns = [

    ...

    path('ajax',
        views.DataTablesAjaxPagination.as_view(), name='report-list-ajax'),

]report_list.html$('#report-table').DataTable({
    columnDefs: [{
        orderable: true,
        targets: -1
    }, ],

    // Ajax for pagination
    processing: true,
    serverSide: true,
    ajax: {
        url: '{% url "reports:report-list-ajax" %}',
        type: 'get',
    },
    columns: [
        // data: json key from prepare_results, name: model field name
        { data: 'number', name: 'number'},
        { data: 'title', name: 'title' },
        { data: 'state', name: 'state' },
        { data: 'year', name: 'year' },
        { data: 'published', name: 'published' },
        { data: 'modified', name: 'modified' },
        { data: 'actions', name: 'actions' }
    ]

});0.1.1 2018‑09‑25Initial release0.1.2 2019‑08‑16Fixedbug when DataTable was set toordering: falsein JavaScript0.1.3 2019‑08‑16Fixedfixed issue where HISTORY.rst was not included in the package causing it to fail upon install0.1.4 2021-08-30Fixedsorting now actually works
Package: django-datatap
Introductiondjango-datatap is a fixture system enabling applications to define their own loading and dumping process while supporting file asset storage.Documentation:https://django-datatap.rtfd.org/RequirementsPython 2.6 or laterDjango 1.3 or laterInstallationPut ‘datatap’ into yourINSTALLED_APPSsection of your settings file.ConceptDatataps are classes able to serialize and deserialize objects in their domain. A datatap maybe chained with another to provide serialization to a particular format or for objects to be read from a general data source like a zip file. Datataps also handle the serialization and deserialization of django File objects within the native objects allowing for assets to follow the application data.Datatap includes a management command to allow dumping and loading to particular data stores (zip file, json file, S3, etc). Some datataps include the originating data tap so that the resulting data store can be automatically detected.Datatap CommandChain a series of datataps with the source starting at the left and the right most to write. Each datatap invocation is seperated by “–”Format:manage.py datatap <datataptype> <datatap vargs> [(-- <datataptype> <datatap vargs>), ...] (-- <destination datataptype> <datatap vargs>)Example command line usage:manage.py datatap Model contenttypes -- Zip -- File archive.zip

manage.py datatap File archive.zip -- Zip -- Model

#3rd party apps can register their own data taps
manage.py datatap DocKitCMS --app=customapp1 --app=customapp2 --collection=blog --publicresource=myblog -- JSON -- Stream > objects.json
Package: django-data-tests
A Django app for specifying validation tests on data in your database.QuickstartInstall Django Data Tests:pip install django-data-testsAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'data_tests.apps.DataTestsConfig',...)Add a data test to one of your existing modelsfromdata_tests.registryimporttest_methodfromdjango.dbimportmodelsclassCat(models.Model):...defmake_noise(self):return'Miaow!'@test_method('Check the cat miaows appropriately')defcheck_cat_sound(self):noise=self.noise()ifnoise!='Miaow!':returnFalse,'Cat made the wrong noise:%s'%noiseelse:returnTrueYou can run your data tests with the management command./manage.pyrundatatestsAlternatively, run them whenever the object is saved in the adminfromdjango.contribimportadminfromdata_tests.adminimportDataTestsAdminMixinclassCatAdmin(DataTestsAdminMixin,admin.ModelAdmin):...History0.1.0 (2019-11-18)First release on PyPI.
Package: django-data-validation
** :warning: this app is still in alpha. expect breaking changes :warning: **A Django app to manage the validation of your data. Inspired bydjango-data-testsread the documentation:https://django-data-validation.readthedocs.iowrite tests on your Django models and view the summary in the adminrun the validation when adding/changing an object via django adminQuick StartRequirementspython >= 3.6django >= 2.2djangorestframework (tested against 3.11)Installationclone the repogitclonehttps://github.com/VersBersh/django-data-validation.gitchange to the django-data-validation directory and install with pippipinstall.In your project, addrest_frameworkanddatavalidationtoINSTALLED_APPSINSTALLED_APPS=(..."rest_framework","datavalidation.apps.DataValidationConfig",...)from your project directory run the database migrations./manage.pymigratedatavalidationWhen running the django-admin server the static files for the datavalidation admin will be served automatically (assuming"django.contrib.staticfiles"is inINSTALLED_APPS). Otheriwse, you should also run./manage.pycollectstaticBasic UsageOn any django model that has data that you would like to validate, add a method decorated with@data_validatorthat returnsPASS,FAILorNA. For instance if you have a model with a start and end time, you can add a data_validator to check that the start time is always before the end timefromdjango.dbimportmodelsfromdatavalidationimportdata_validator,PASS,FAIL,NAclassYourModel(models.Model):...start_time=models.DateTimeField()end_time=models.DateTimeField(blank=True,null=True)...@data_validatordefcheck_start_time(self):""" check that the start time is before end time """ifself.end_timeisNone:returnNA("end time not set")elifself.start_time<self.end_time:returnPASSelse:returnFAIL("end time is before start time!")To run the validation for all models./manage.pyvalidateor for a specific model./manage.pyvalidateyourapp.YouModelSeeWriting Data Validatorsfor more details and examples of data validatorsOptionally, you can add thedata_validaiton.models.DataValidationMixinto your models to provide some additional methods for querying the validation resultsfromdatavalidation.modelsimportDataValidationMixinclassYouModel(DataValidationMixin,models.Model):...# in a shellprint(YouModel.datavalidation_status)>>>Status.PASSING# hopefully :)Finally, you can also adddata_validaiton.admin.DataValidationMixinto your django admin classes to review the data in the admin. SeeSetting up the Adminfor details.
Package: django-dated-values
A reusable Django app that allows adding dated decimal values to any Django model.InstallationTo get the latest stable release from PyPipipinstalldjango-dated-valuesTo get the latest commit from GitHubpipinstall-egit+git://github.com/bitmazk/django-dated-values.git#egg=dated_valuesTODO: Describe further installation steps (edit / remove the examples below):Adddated_valuesto yourINSTALLED_APPSINSTALLED_APPS=(...,'dated_values',)Add thedated_valuesURLs to yoururls.pyurlpatterns=patterns('',...url(r'^dated-values/',include('dated_values.urls')),)Don’t forget to migrate your database./manage.pymigratedated_valuesAdd css or write your own custom styles.{% load static %}<linkhref="{% static "dated_values/css/dated_values.css"%}"rel="stylesheet">UsageThe usage is fairly straight forward. You need to addDatedValueTypeinstances for every content type, that you want values to be added to.Thedecimal_placesfield allows you to lower the amount of decimal places
for form validation. It defaults to 2 and its max is 8.NoteUsing postgres, it stores the full range of decimal places, no matter
if you input less.If you sethiddentoTrueusing the default template automatically
hides the values in the form. You can e.g. use it to log values in the
background without them being visible for users.If you just seteditabletoTrueusing the default template will
render only the values and no input fields.Once you’ve set that up and visit the management view, you will see a form
table which holds all the values from all defined types for that item.
The url kwargs requirectype_idandobject_id. An example
implementation might be:classMyModel(models.Model):...# my fields and other things go heredefget_management_url(self):"""Returns the management url from django-dated-values."""ctype=ContentType.objects.get_for_model(self.__class__)returnreverse('dated_values_management_view',kwargs={'ctype_id':ctype.id,'object_id':self.id})SettingsTheDATED_VALUES_ACCESS_ALLOWEDsetting expects a function, that takes the
user and the content object as arguments. It is required to define the access
permission for the values management view. Default is as follows:DATED_VALUES_ACCESS_ALLOWED=lambdauser,obj=None:user.is_staffNotesuperusers will always be able to open the view, regardless of what
is set here.You can change the lenght of displayed items, defaulting to 14 (2 weeks) by
settingDATED_VALUES_DISPLAYED_ITEMS:# this will only show 1 weekDATED_VALUES_DISPLAYED_ITEMS=7ContributeIf you want to contribute to this project, please perform the following steps# Fork this repository
# Clone your forkmkvirtualenv-ppython2.7django-dated-valuesmakedevelopgitco-bfeature_branchmaster# Implement your feature and testsgitadd.&&gitcommitgitpush-uoriginfeature_branch# Send us a pull request for your feature branch
Package: django-date-extensions
django-date-extensions
by Matthew SomervilleThis code adds a few small extensions to Django’s DateField, to handle both
approximate dates (e.g. “March 1963”) and default year dates (e.g. assume
“24th June” is the most recent such).example contains a hopefully self-contained Django project that simply shows
off a form with these methods of entry.Approximate datesA new object, ApproximateDate, is used to represent dates that might not have a
month or a day. ApproximateDateField is the model field used to represent these
objects in a Model, and ApproximateDateFormField is the field used in a Django
form. Everything should work seamlessly simply by specifying a model field as
ApproximateDateField rather than DateField.Default year datesPrettyDateField is a form field to be used on DateField model fields. It takes
one argument, future, which is a nullable boolean. If True, a date input that
is missing a year will be taken to be the next possible occurrence of that date
- e.g. on 24th November 2009, entering 24th December will be taken to be
2009-12-24, whilst entering 3rd March will be taken to be 2010-03-03. If future
is False, the reverse occurs, with year-less dates being assumed to be the
closest occurrence of that date in the past.If future is not set, then PrettyDateField acts the same as a DateField, only
allows suffixes on ordinals, and assumes D/M/Y rather than M/D/Y.TestingRun ‘tox’ with tox installed.TodoImprove date parsing to take more inputs like my traintimes.org.uk PHP, such as
“next Friday”.Any queries or comments, do get in touch. Something’s probably broken, as I tried
to tidy up the code a little for public release :)Matthew Somerville.
Package: django-datefilterspec
.. image:: https://travis-ci.org/tzulberti/django-datefilterspec.svg?branch=master:alt: Build status:target: https://travis-ci.org/tzulberti/django-datefilterspecdjango-daterange-filter=======================Add the option to filter by a custom date range on the admin. This allowsto inputs to be used to get the custom date range filters.See datefilter.png of a screenshot of how this is seen on the admin.**IMPORTANT:** this will work with Django 1.4. I won't work with previous Djangoversions.Installation------------Use pip/easy_install.. code-block:: bashpip install django-daterange-filterAdd daterange_filter to settings.INSTALLED_APP. For this, edit the setup.pyfile:.. code-block:: pythonINSTALLED_APPS = (...'daterange_filter')After this, if you have a model like this one:.. code-block:: pythonclass MyModel(models.Model):...foo = models.CharField(max_length=1, choices=BAR_CHOICES)created_at = models.DateField()To allow to filter the **created_at** field using the date ranges, you mustedit the admin.ModelAdmin referenced to that class:.. code-block:: pythonfrom daterange_filter.filter import DateRangeFilterfrom django.contrib import adminfrom models import MyModelclass MyModelAdmin(admin.ModelAdmin):list_filter = ('foo',('created', DateRangeFilter), # this is a tuple...)DateRangeFilter honours localization and supports local dateformats for filtering.Running tests-------First :code:`pip install -r requirements.txt`, then :code:`python ./runtests.py`If you wanna run tests on all supported Python/Django versions, execute :code:`tox`.Changes-------1.3.0:* Fixed calendar icon moving to a new line in Django 1.9 (Special thanks to https://github.com/farooqaaa)* fix daterange_filter function (Special thanks to https://github.com/ZamorakLin)1.1.1:* Special thanks to: https://github.com/mightygraf0.2.0:* Updated README* Works with DateTime (special thanks to Andrea Rabbaglietti)0.1.1:* Removed the custom DateRangeField* Improved i18n* Special thanks to: https://github.com/DXist
Package: django-datepick
Django-datepick is a Django app to add a date, time and datetime pickers to
your forms.InstallInstall the app withpip installdjango-datepick.Usage with formsChange the widget used in yourforms.pyto use the widgets included in this app:from django import forms
from datepick import widgets

class MyForm(forms.Form):
    date_field = forms.DateField(widget=widgets.DateInput)
    datetime_field = forms.DateTimeField(widget=widgets.DateTimeInput)
    time_field = forms.TimeField(widget=widgets.TimeInput)Usage with modelsChange the field used in yourmodels.pyto use the fields from this app:from django.db import models
from datepick import fields

class MyDateModel(models.Model):
    d = fields.DateField()
    dt = fields.DateTimeField()
    t = fields.TimeField()Override the admin widgetSame as with any widget, register the model overriding the widget(s) inadmin.py:from datepick.widgets import DateInput, SplitDateTimeWidget, TimeInput

class MyDateModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.DateField: {"widget": DateInput},
        # DON'T models.DateTimeField: {"widget": DateTimeInput}
        models.DateTimeField: {"widget": SplitDateTimeWidget}
        models.TimeField: {"widget": TimeInput},
    }DateTimeInputdoesn’t work in the admin, as it expects a multivalue field.Why?Each time you use a date field in Django, the form is a text input. Any
frontend would like a datepicker of somekind. Turns out browsers and cellphones
already have a datepicker. It looks like this in a browser:And looks like this in a cellphone:It doesn’t need Javascript or extra CSS.More info:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/timehttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datehttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
Package: django-daterangefilter
Django admin date range filterApplication adds three Django admin list filters:DateRangeFilter,PastDateRangeFilterandFutureDateRangeFilter. These filters let user filter models by date range.PastDateRangeFilterandFutureDateRangeFilteradd quick selection of predefined date ranges. Filters can be applied to any model date fields. Application supports default Django admin theme andSuit theme.RequirementsPython 2.7+ or Python 3.3+Django 1.9+InstallationInstalldjango-daterangefilterusing pip:pipinstalldjango-daterangefilterAdddaterangefiltertoINSTALLED_APPS. Example:INSTALLED_APPS=(...'daterangefilter',...)Application uses static files so do not forget to issuecollectstaticmanagement command in production environment.Example usagein admin.py:fromdjango.contribimportadminfromdaterangefilter.filtersimportPastDateRangeFilter,FutureDateRangeFilter@admin.register(Post)classPostAdmin(admin.ModelAdmin):list_filter=[('created_at',PastDateRangeFilter),('publish_at',FutureDateRangeFilter)]Advanced usagePredefined ranges can be completely redefined by overriding_past_ranges.htmland_future_ranges.htmltemplates.
Take into account that these templates are inserted in the middle of the javascript code and may contain nothing but ranges
definition. For more examples on usingmomentlibrary refer tolibrary documentation.CreditsFilter widget uses a great JavaScript date range picker component -Date Range Pickerby Dan Grossman.
Package: django-daterange-filter
.. image:: https://travis-ci.org/tzulberti/django-datefilterspec.svg?branch=master:alt: Build status:target: https://travis-ci.org/tzulberti/django-datefilterspecdjango-daterange-filter=======================Add the option to filter by a custom date range on the admin. This allowsto inputs to be used to get the custom date range filters.See datefilter.png of a screenshot of how this is seen on the admin.**IMPORTANT:** this will work with Django 1.4. I won't work with previous Djangoversions.Installation------------Use pip/easy_install.. code-block:: bashpip install django-daterange-filterAdd daterange_filter to settings.INSTALLED_APP. For this, edit the setup.pyfile:.. code-block:: pythonINSTALLED_APPS = (...'daterange_filter')After this, if you have a model like this one:.. code-block:: pythonclass MyModel(models.Model):...foo = models.CharField(max_length=1, choices=BAR_CHOICES)created_at = models.DateField()To allow to filter the **created_at** field using the date ranges, you mustedit the admin.ModelAdmin referenced to that class:.. code-block:: pythonfrom daterange_filter.filter import DateRangeFilterfrom django.contrib import adminfrom models import MyModelclass MyModelAdmin(admin.ModelAdmin):list_filter = ('foo',('created', DateRangeFilter), # this is a tuple...)DateRangeFilter honours localization and supports local dateformats for filtering.Running tests-------First :code:`pip install -r requirements.txt`, then :code:`python ./runtests.py`If you wanna run tests on all supported Python/Django versions, execute :code:`tox`.Changes-------1.3.0:* Fixed calendar icon moving to a new line in Django 1.9 (Special thanks to https://github.com/farooqaaa)* fix daterange_filter function (Special thanks to https://github.com/ZamorakLin)1.1.1:* Special thanks to: https://github.com/mightygraf0.2.0:* Updated README* Works with DateTime (special thanks to Andrea Rabbaglietti)0.1.1:* Removed the custom DateRangeField* Improved i18n* Special thanks to: https://github.com/DXist