Saravanan666/pypi-org huggingface dataset:
Package: django-simple-timeseries
django-simple-timeseriesSerializes small, simple timeseries to a database with Django. Provides theTimeseriesclass for manipulating timeseries, and theTimeseriesFieldcustom field type for serializing.Status: Experimental.ExampleDefine aTimeseriesFieldon a model:fromdjango.dbimportmodelsfromdjango_simple_timeseriesimportTimeseriesFieldclassAppliance(models.Model):name=models.CharField(max_length=64)temperature=TimeseriesField(resolution_seconds=60*60,max_points=24,help_text='Last 24 hours of temperature data',)You can then accessTimeseriesmethods on it:>>>a=Appliance(name='fridge')>>>a.temperature.add(23.2)>>>a.save()>>># Wait some time.>>>a.temperature.add(26.5)>>>a.save()>>>print(list(a.iter_points()))[(datetime(2020,1,1,2,30,0,tzinfo=<UTC>),23.2),(datetime(2020,1,2,2,30,0,tzinfo=<UTC>),26.5),]RequirementsThis package supports and is tested against the latest patch versions of:Python:3.7, 3.8, 3.9Django:2.2, 3.0, 3.1MariaDB:10.2, 10.3, 10.4, 10.5MySQL:5.7, 8.0Oracle:12.2+ (only tested against 12.2.0.1 SE)PostgreSQL:9.5, 10, 11, 12SQLite:3.9.0+All database backends are tested with the latest versions of their drivers. SQLite is also tested on GitHub Actions' latest macOS and Windows virtual environments.Installationpip install django_simple_timeseriesFor Django 3.1 and newer, no additional dependencies are required. For earlier versions, this project requiresdjango_jsonfield_backport:pip install django_jsonfield_backportHow it worksTimeseriesTheTimeseriesclass implements a simple vector-like timeseries. Timeseries data is always contiguous.Internally, all timeseries instances have:.start_time, adatetime.datetimecorresponding to the first data point;.data, the recorded data points (or y-values); and.resolution, a timedelta which describes the fixed interval between samples.Samples are added by calling theadd()method. Theadd()method ensures contiguousness with the following policy:If fewer thanresolutionseconds have elapsed since the most recent sample, the most recent sample is replaced.If more thanresolutionseconds have elapsed since the last sample, the vector is extended by the appropriate number of samples (time_delta % resolution - 1), each which will be recorded as gaps with the valueNone.In all cases, the vector is trimmed to no more thanmax_pointssamples.TimeseriesFieldTimeseriesFieldis implemented as, and extends, aJSONField. TheTimeseriesmethods.to_object()and.from_object()serialize aTimeseriesinstance to and from plain python objects, which the custom field type transparently implements.Usage NotesThis module is experimental and hasn't been exhaustively tested. It is not intended for large timeseries. Use at your own risk!
Package: django_simpletree
========Django SimpleTree========This is a simple Django apllication that provide an abstract class to create tree style models.Using this model we can define unlimited number of subbranches only by one model class.It also provides a django admin abstract class which helps to have a tree style list in the admin site.Installation============Install the application package using pip::pip install django-simpletreeadd 'simpletree' to the INSTALLED_APPS list on your settings fileHow to use==========Import the Node abstract model from simpletree and use it to create your tree style model::from simpletree.models import Nodeclass MyModel(Node):passIn your application admin.py file import the NodeAdmin abstract ModelAdmin class and use it to register your model to the admin site::from simpletree.admin import NodeAdminclass MyAdmin(NodeAdmin):class Meta:model = MyModel
Package: django-simpletwitchauth
Wanna enable your awesome Django application to register and
authenticate user using Twitch profiles?This application was created especially for your needsFeaturesEasy to useReady to Twitch channel name changesUsername cases are synchronized to Twitch display_nameUser emails are synchronized to TwitchInstallationEnsure thatDjango ‘sites’ frameworkis enabled.Python package:pip install django-simpletwitchauthsettings.py:Addtwitch_authto INSTALLED_APPSAddtwitch_auth.backends.OAuth2Backendto AUTHENTICATION_BACKENDSSetTwitch applicationsettingsExample using django-environ:env = environ.Env()

TWITCH_AUTH_CLIENT_ID = env('TWITCH_CLIENT_ID', default='some_client_id')
TWITCH_AUTH_CLIENT_SECRET = env('TWITCH_CLIENT_SECRET', default='some_client_secret')All available settings:TWITCH_AUTH_SCOPEDefines OAuth2 token scopeDefaults touser_readTWITCH_AUTH_PROTOCOLDefines protocol that is used to build full authentication callback URIDefaults tohttp://TWITCH_AUTH_CLIENT_IDDefines Twitch application client IDTWITCH_AUTH_CLIENT_SECRETDefines Twitch application client secretTWITCH_AUTH_REDIRECT_URIDefines default redirect URI after successful authenticationDefaults to/UsageRun migrations to create database tables for entities.Add somewhere in your templates link to urllogin_twitch
Package: django-simpleui-captcha
django-simpleui-captchadjango-simpleui-captcha 是一个 django 后台管理登录验证码插件界面安装pip install django-simpleui-captcha依赖Djangodjango-simple-captcha快速开始1. 添加 "simpleui_captcha" 到 INSTALLED_APPS 设置, 注意要放在最前面INSTALLED_APPS=["simpleui_captcha","simpleui",...]2. 添加simpleui_captcha的url到你的项目urls.py::path('simpleui_captcha/',include('simpleui_captcha.urls')),3. 运行python manage.py migrate迁移验证码模型4.(可选)后台在连续登录n次失败后,要求输入验证码登录# urls.pyfromsimpleui_captcha.viewsimportLoginWithCaptchaurlpatterns=[path('admin/login/',LoginWithCaptcha.as_view(),name='admin_login'),path('admin/',admin.site.urls),...]# settings.py 默认值SIMPLEUI_CAPTCHA={'FAILED_LOGIN_COUNT_NAME':'failed_login_count',# session 的键名'MAX_FAILED_LOGIN_COUNT':3,# 不需要输验证码的最大失败次数}
Package: django-simple-viewset
Simple viewset for models CRUD operations.# myapp/models.pyfromdjango.dbimportmodelsclassMyModel(models.Model):...classMeta:...default_permissions=('add','change','delete','read')# myapp/views.pyfromviewsetimportModelViewSetfrom.modelsimportMyModelclassMyModelViewSet(ModelViewSet):model=MyModel# myapp/urls.pyfromdjango.conf.urlsimportincludefrommyapp.viewsimportMyModelViewSeturlpatterns=[url(r'',include(MyModelViewSet().urls())),]# settings.pyINSTALLED_APPS=['simple_viewset',]
Package: django-simple-vite
django-simple-viteA simple Django app to integrate Vite.js easily in your Django project.Install:pip install django-simple-viteThen addsimple_vitetoINSTALLED_APPSin Django settings.INSTALLED_APPS = [
    ...
    'simple_vite',
    ...
]Settings:During development, setVITE_SERVER_URLin Django settings, pointing to the Vite.js development server, e.g.:VITE_SERVER_URL = 'http://localhost:3000'When in production, you don't need to setVITE_SERVER_URL, because the compiled assets produced by Vite.js will be served as regular static files.Usage:Create an app that will contain your Vite.js powered frontend:./manage.py startapp frontendInside your app, create avite_srcdirectory (the name is arbitrary). This directory will contain your Javascript sources, that will be compiled by Vite.js.In thevite_srcdirectory, create avite.config.jsfile, with this content:const { resolve } = require('path');

export default {
    build: {
        manifest: true, // adds a manifest.json
        rollupOptions: {
            input: [
              // Use main.js file as entrypoint for your JS app.
              resolve(__dirname, './main.js'),
            ]
        },
        // Puts the Vite.js manifest.json in
        // PROJECT_ROOT/frontend/static/
        outDir:  '../static',
        // puts compiled asset files (js, css) in
        // PROJECT_ROOT/frontend/static/frontend
        assetsDir:  'frontend',
    },
    plugins: [],
    server: {
        // This port should match with VITE_SERVER_URL Django setting.
        port: 3000,
        open: false,
    }
};In thevite_srcdirectory, create amain.jsfile, that will serve as entry point for your app, with this content:// Add this at the beginning of your app entry.
import 'vite/modulepreload-polyfill';
import 'main.css';

console.log("hello world");main.cssis a CSS file that will be imported by Vite and used by your application.Install Vite.js in yourvite_srcdirectory:yarn add viteAdd a couple of script in yourpackage.json:{
  "dependencies": {
    "vite": "^4.1.4"
  },
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  }
}Launch Vite.js server:yarn devCreate a Django templateindex.htmlthat will hold the HTML markup used by your application, save it inside yourfrontendDjango app in a subdirectorytemplates/frontend/.{% load vite %}

<html>
<head>
    {% vite_styles 'main.js' %}
</head>
<body>
    <h1>Hello world</h1>

    {% vite_scripts 'main.js' %}
</body>

</html>Now create a Django URLConf that will serve the above template, and you'll see a basic Vite.js powered web app, with Hot Module Replacement (HMR) enabled!
Package: django-simple-worker
Django Simple WorkerInstallationpipinstalldjango-simple-workerAdd to installed apps:INSTALLED_APPS=['simpleworker',]Add to your urls (optional):path('simpleworker/',include(('simpleworker.urls','simpleworker'),namespace='simpleworker')),ConfigurationAdd to Django settings:SIMPLE_WORKER_SYNC_PROCESSING=env.bool('SIMPLE_WORKER_SYNC_PROCESSING',default=False)UsageTODO
Package: django-simulated-inlines
Django Simulated InlinesDescriptionThis package extends the ModelAdmin interface with the possibility to create custom inlines
that can contain a list of any Model instances, the relationship with the base change_form is not needed.Featuresinlines can be collapsedsupports inline subtitlespaginationcustom links for any inline celldynamic fieldsaction buttonsInstallationInstall:pip install django_simulated_inlinesadd to INSTALLED_APPS:INSTALLED_APPS = [
        ...
        'django_simulated_inlines',
    ]How to UseImport the ModelAdmin and Inline classesfrom django_simulated_inlines.admin import SimulatedInline, SimulatedInlinesModelAdminDeclarating inlines:class ExampleInline(SimulatedInline):
    model = ExampleModel
    verbose_name = _("example")
    verbose_name_plural = _("examples")
    per_page = 20
    buttons = ("example_button", )
    collapse = True
    fields = (
        "id"
        ("custom_link", "/admin/custom/link/%s/"),
        "custom_field",
    )

    def custom_field(self, obj):
        """The return of this function is the value on the field cell"""
        return f"Custom field for {self.field}"
    custom_field.short_description = _("custom field")

    def example_button(self, request, object_id):
        """This function is called when the button is pressed"""
        execute_code()
    example_button.short_description = _("Execute example button")

    def get_subtitle(self, request, object_id):
        """Override this to define a subtitle for the inline"""
        return "this is a subtitle"

    def get_queryset(self, request, object_id, parent_queryset):
       """Override this to filter or customize de queryset"""
       return self.model.objects.filter(x=object_id).all()Add the inlines to theSimulatedInlinesModelAdmin.simulated_inlines.class ExampleModelAdmin(SimulatedInlinesModelAdmin):
    simulated_inlines = [ExampleSimulatedInline]Requirements
Package: django-singleactiveobject
#django-singleactiveobjectModel mixin that ensures there is only one active model instance in your database.## What is this app good for?This might come in handy if you store some sort of configuration in your databasebut want to be sure there is only one active entry at a time.## How it worksUpon save() this will check if the current object is active=True and will setany other active object to active=False ensuring there is only one active.## Download/Install### using pippip install django-singleactiveobject### githubgit clone https://github.com/byteweaver/django-singleactiveobject## Usage```pythonfrom singleactiveobject.models import SingleActiveObjectMixinclass YourModel(SingleActiveObjectMixin):...your stuff```## TestingJust run the makefile to set up a virtual environment for testingmakeStart the test runnermake test
Package: django-singlelogin
#Single LoginSingle login is a Django app that will restrict concurrent login.Quick startAdd “singlelogin” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'singlelogin',
]Add “singlelogin.middleware.OneSessionPerUserMiddleware” to your MIDDLEWARE like this:MIDDLEWARE = [
    ...
    'singlelogin.middleware.OneSessionPerUserMiddleware',
]Runpython manage.py migrateto create the singlelogin models.That is all.
Package: django-single-table-db-storage
This Python package provides a Django storage implementation that uses a single database table.Django developers may find this package to be most helpful for use in their test and prototype environments.
This package may also be useful in launching small-scale projects/environments quickly without needing additional infrastructure setup.WARNING:For production applications, please consider using a CDN instead of this package, as it is not a good practice to serve files from a database. Website performance will suffer! Please see the section "Alternatives" below for performant and scalable storage options.Features / BenefitsEasy to install and configure.Serve files properly when there are multiple django servers under a load balancer.Files persist in database when application server is rebuilt (as long as database is not hosted on the application server).In unit testing scenarios, created files can be automatically "rolled back" out of existence if the unit test uses a transaction, which is howdjango.test.TestCaseworks.Installationpipinstalldjango-single-table-db-storageSetupIn your django settings file, add'django_single_table_db_storage'toINSTALLED_APPS.INSTALLED_APPS=[...'django_single_table_db_storage',...]Also in your django settings file, set up the default storage. It is recommended that you add a TODO to remind yourself to use a better storage in the future.# TODO: As this project scales, a CDN or S3-compatible storage for production#       might be a better solution.DEFAULT_FILE_STORAGE='django_single_table_db_storage.storage.SingleTableDbFileStorage'In your django settings file, you should determine the default accesibility of the files that are uploaded.DJANGO_SINGLE_TABLE_DEFAULT_PUBLIC=True# or set it to False. The default is False.Mount the URLs where you want in yoururls.pyfile.urlpatterns=[...path('files/',include('django_single_table_db_storage.urls')),....]Run the database migrations to create the table../manage.pymigrate...And now your environment is set to use the file storage.AlternativesYou can find other file storage alternatives for Django here:https://djangopackages.org/grids/g/storage-backends/This package contains a similar and possibly better implementation to this library, depending on your use case and license that you prefer:https://github.com/kimetrica/django-binary-database-files/
Package: django-singleton
# django-singletondjango-singleton is a fork of Thomas Ashelford’s [django-singletons](https://github.com/tttallis/django-singletons).I forked his code to include Django 1.4 compatibility, as well as to remove the delete button within the admin (see credit below).  I had to rename the repository so that I could submit this to the Python Package Index.Now includes Django 1.6 support, while maintaining backwards compatibility.[Code from Chris Church’s fork](https://github.com/ninemoreminutes/django-singletons/commit/9b231666b9027d3bd1159f3db8bce34701193bdd) - I am merely synthesizing all this..## In Thomas’s wordsI keep finding myself re-using this simple bit of code, so I thought I should open-source it, even though it’s not much more than a snippet.A SingletonModel is a django model that only ever has one record. You can’t use the admin to create a new instance, or delete the existing one.Some might argue that singleton models are an inefficient way of using a relational database, but in practice it’s no biggie - most web sites have some important one-off content (eg. the Home Page), and  singleton models map well to how content editors generally think.I suspect I have cadged some of this code from someone else (likely ex-colleaguehttp://github.com/jphalip/), but a quick Google doesn’t show up anything like this already out there. So here it is. I hope you find it useful.### Installationpip install django-singletonTo get the custom admin templates working, you need to add “singleton_models” to your INSTALLED_APPS### Example Usagein models.pyfrom singleton_models.models import SingletonModelclass HomePage(SingletonModel):welcome = models.TextField()def __unicode__(self):return u”The Home Page” # something like this will make admin message strings more coherentclass Meta:verbose_name = “Home Page” # once again this will make sure your admin UI doesn’t have illogical text
verbose_name_plural = “Home Page”in admin.pyfrom singleton_models.admin import SingletonModelAdmin
from models import HomePageadmin.site.register(HomePage, SingletonModelAdmin)
Package: django-singleton-admin
=====django-singleton-admin=====This package provides a way to ensure singleton classes can only have one instance in theDjango admin panel. The package contains:* admin.py, which defines the SingletonAdmin class, preventing adding if an instance already exists.* templates/admin/singleton_enabled_base.html, which hides the relevant "add" buttons on the admin.The admin.py file is taken directly from Mezzanine by Stephen McDonald,https://bitbucket.org/stephenmcd/mezzanine/src/The template file is taken from a talk at SyDjango by Stephen McDonald,http://blog.jupo.org/2012/10/26/sydjango-talk-django-admin-missing-manual/Requirements--------------See Mezzanine for more details.Quick start-----------1. Add the app to your INSTALLED_APPS setting like this::INSTALLED_APPS = (...'django_singleton_admin',)2. In your singleton model's admin.py file, register it with the admin using this class, e.g.::from django_singleton_admin.admin import SingletonAdminclass GlobalSettingsAdmin(SingletonAdmin):passadmin.site.register(BSGlobalSettings, GlobalSettingsAdmin)3. Extend the admin template "admin/base_site.py" using the provided base instead ofof the usual "admin/base.html", i.e. using:{% extends "admin/singleton_enabled_base.html" %}Note that this template uses the "extrastyle" block, so if you also override that, youwill need to copy the contents of the provided template into your code instead.(In that case you may not need to add the app to your installed apps either.)
Package: django-singleton-admin-2
Django Singleton AdminIn dynamic applications, it can be somewhat of a pain to have static settings thathaveto be set insettings.py. Django Singleton Admin adds an easy way to edit singleton models (e.g a SiteSetting model) to allow administrators to change configuration on the fly.This is great for things like OAuth settings for third parties, or dynamic settings that you need to pull for your site.InstallationInstall with Pippip install django-singleton-admin-2Adddjango_singleton_admintoINSTALLED_APPSInfluenced Byhttps://github.com/RacingTadpole/django-singleton-adminhttps://github.com/lazybird/django-soloExample# models.py
from django.db import models

class SiteSettings(models.Model):
    site_title = models.CharField(max_length=32)
    site_domain = models.CharField(max_length=32)
    site_description = models.CharField(max_length=32)

    @staticmethod
    def get_instance():
        return SiteSettings.objects.get_or_create(pk=0)
        
    def __str__(self):
        return "Site settings"# admin.py
from django.contrib import admin
from .models import SiteSettings
from django_singleton_admin.admin import DjangoSingletonModelAdmin

admin.site.register(SiteSettings, DjangoSingletonModelAdmin)
Package: django-singleton-model
Django Singleton ModelSingleton design-pattern implementation for using with django models and
works with more recent versions of djangoInstallingInstall the package$pip3installdjango-singleton-modeland that’s it. Don’t add it to INSTALLED_APPS.UsingImport the SingletonModel class and inherit from itfromsingleton_modelimportSingletonModelclassMySingleModel(SingletonModel):passRunning testsGo into example folder$cdexampleand run them$./manage.pytestTroubleshootingCheck the example folder if you have any doubts. Or you can create an
issue.
Package: django-sirtrevor-file
django-sirtrevor-file=====================**django-sirtrevor-file** is a file block for `django-sirtrevor`_.Quick start-----------1. Install django-sirtrevor-file::pip install django-sirtrevor2. Add ``sirtrevor_file`` to your INSTALLED_APPS setting like this::INSTALLED_APPS = (...'sirtrevor','sirtrevor_file',)3. Add `File` block type to the list of supported block types in``settings.py``::SIRTREVOR_BLOCK_TYPES = ['Text', 'List', Image', 'Video', 'File']The «File» block type should now be available wherever you use a``SirTrevorField`` in your project.License-------MIT_.. _django-sirtrevor: https://github.com/philippbosch/django-sirtrevor
Package: django-siteajax
https://github.com/idlesign/django-siteajaxDescriptionReusable application for Django bridging client and server sidesStreamline your server and client interaction using declarative techniques
in your HTML and helpful abstractions fromsiteajaxin your Python code.NoteThe client side ofsiteajaxis powered byhtmx(the successor ofintercooler.js) -https://htmx.org/UsageSomewhere in yourviews.py:fromdjango.shortcutsimportredirect,renderfromsiteajax.toolboximportajax_dispatchdefget_news(request):news=...# Here we fetch some news from DB.# We could access `request.ajax` object properties# or even drive client side with the help# of siteajax.toolbox.AjaxResponse but for this demo# simple rendering is enough.returnrender(request,'sub_news.html',{'news':news})@ajax_dispatch({# Map request source element id (see html below)# to a handler.'news-list':get_news,})defindex_page(request):"""Suppose this view is served at /"""returnrender(request,'index.html')Now to yourindex.html:<!DOCTYPE html><html><head><!-- Get client library js from CDN. -->{% include "siteajax/cdn.html" %}</head><body><divid="news-list"hx-gethx-trigger="load"></div><!-- The contents of the above div will be replaced
        with the news from your server automatically fetched on page load.
        Notice `hx-*` attributes driving htmx JS library.
        Also notice how `id="news-list"` is used by `@ajax_dispatch`
        view decorator (shown above). --></body></html>At lastsub_news.html(nothing special):{% for item in news %}<div>{{ item.title }}</div>{% endfor %}Documentationhttps://django-siteajax.readthedocs.org/