Saravanan666/pypi-org huggingface dataset:
Package: django-concat-js
Concat JSTable of ContentsUse caseInstallationSettingsUsageLicenseUse caseThis small app aim to provide automatic concatenation of javascript (or any other file) files.
Typical use case is to combine sets of small js files and bundle then into one functionnal script for each «web page», and reduce the overhead of multiple web requests.InstallationFirst of all install the app from PyPipip install django-concat-jsAfter installing the package, addconcat_jsin in yourINSTALLED_APPSsettingsINSTALLED_APPS=(...'concat_js',)SettingsYou need to configure the app before using it. It's done by adding a setting in yoursettings.pyfileCONCAT_JS={"JSON_DEPS":aPathtomainJSONfile,"CONCAT_ROOT":aPath,"CREATE_SOURCEMAPS":False,"LINT_COMMAND":False,"FILTER_EXTS":(".js",),"LINT_BASE":False}The main setting here isJSON_DEPwhich should point to a JSON file. It can be aPathor a string.
This files contains a list of objects with following attributes{"relative_to":"{BASE_DIR}/my_path/","dest":"first_destination.js","src":["src/first_source.js","src/second_source.js"]}relative_tois an optionnal string containing an absolute path to a directory. All other path in this object are considered relative to this directory. Defaults toCONCAT_ROOT(see below). You can useBASE_DIR(defined in django defaultsettings.pyfile) orCONCAT_ROOTas format placeholder.srcis a list of relative path to files to be concatenated. The result is in....destis the relative path to the concatenated file.If you want to, you can name each bundle and use the more verbose["my_wonderful_name",bundle_spec]wherebundle_specis an object described above.Other settingsCONCAT_ROOTis aPathor string setting. See aboce for meaning. It defaults toBASE_DIRCREATE_SOURCEMAPis a boolean, which defaults toFalse. IfTrue, each bundling will also create a sourcemap file named{dest}.mapLINT_COMMANDmust beFalseor a command string used to invoke a linter for each file before concatenation.FILTER_EXTSis an iterable of extension strings which defaults to the tuple(".js", ). Only files with given extensions will be watched for changes.LINT_BASEis eitherFalse(the default) or a path to a directory. Files in this directory will be linted just before watching for changes.## UsageOnce configured, you can watch for changed files withpythonmanage.pywatch_jsLicensedjango-concat-jsis distributed under the terms of theMITlicense.
Package: django-concurrency
Django Concurrencydjango-concurrency is anoptimistic lockimplementation for Django.It prevents users from doing concurrent editing in Django both from UI and from a
django command.How it worksfromdjango.dbimportmodelsfromconcurrency.fieldsimportIntegerVersionFieldclassConcurrentModel(models.Model):version=IntegerVersionField()name=models.CharField(max_length=100)Now if you try::a=ConcurrentModel.objects.get(pk=1)a.name='1'b=ConcurrentModel.objects.get(pk=1)b.name='2'a.save()b.save()you will get aRecordModifiedErroronb.save()Similar projectsOther projects that handle concurrent editing aredjango-optimistic-lockanddjango-lockinganyway concurrency is "a batteries included" optimistic
lock management system, here some features not available elsewhere:can be applied to any model; not only your code (ie. django.contrib.auth.Group)handlelist-editableChangeList. (handle#11313 <https://code.djangoproject.com/ticket/11313>_)manage concurrency conflicts in admin's actionscan intercept changes performend out of the django app (ie using pgAdmin, phpMyAdmin, Toads) (usingTriggerVersionField)can be disabled if needed (seedisable_concurrency)ConditionalVersionFieldto handle complex business rulesProject LinksCode:https://github.com/saxix/django-concurrencyDocumentation:https://django-concurrency.readthedocs.org/en/latest/Issue Tracker:https://github.com/saxix/django-concurrency/issuesDownload Package:http://pypi.python.org/pypi/django-concurrency/
Package: django-conditional-aggregates
(Django 1.4 and 1.5 are not possible due to limitation of older `SQLCompiler` class)Note: from Django 1.8 on this module is not needed as support is built-in:https://docs.djangoproject.com/en/1.8/ref/models/conditional-expressions/#caseSometimes you need some conditional logic to decide which related rows to ‘aggregate’ in your aggregation function.In SQL you can do this with aCASEclause, for example:SELECTstats_stat.campaign_id,SUM(CASEWHEN(stats_stat.stat_type=aANDstats_stat.event_type=v)THENstats_stat.countELSE0END)ASimpressionsFROMstats_statGROUPBYstats_stat.campaign_idNote this is different to doing Django’s normal.filter(...).aggregate(Sum(...))…what we’re doing is effectively inside theSum(...)part of the ORM.I believe these ‘conditional aggregates’ are most (perhapsonly) useful when doing aGROUP BYtype of query - they allow you to control exactly how the values in the group get aggregated, for example to only sum up rows matching certain criteria.Usage:pip installdjango-conditional-aggregatesfromdjango.db.modelsimportQfromdjconnaggimportConditionalSum# recreate the SQL example from above in pure Django ORM:report=(Stat.objects.values('campaign_id')# values + annotate => GROUP BY.annotate(impressions=ConditionalSum('count',when=Q(stat_type='a',event_type='v')),))Note that standard DjangoQobjects are used to formulate theCASEWHEN(...)clause. Just like in the rest of the ORM, you can combine them with() | & ~operators to make a complex query.ConditionalSumandConditionalCountaggregate functions are provided. There is also a base class if you need to make your own. The implementation ofConditionalSumis very simple and looks like this:fromdjconnagg.aggregatesimportConditionalAggregate,SQLConditionalAggregateclassConditionalSum(ConditionalAggregate):name='ConditionalSum'classSQLClass(SQLConditionalAggregate):sql_function='SUM'default=0
Package: django-conditional-views
Simple ETag and Last-Modified mixins for class based views.What is Django Conditional Views?Django Conditional Views builds off of the built indjango conditional view processingmachinery
to provide simple mixins for class based views that implement support for the ETag and Last-Modified
conditional request headers.FeaturesInherit one of these mixins to make your TemplateView’s, DetailView’s, or ListView’s:Calculate and append ETag and/or Last-Modified headers to the response and;Respond with a304 Not Modifiedor a412 Precondition Failedto requests that provide conditional response headers such as If-Modified-SinceHelpful DefaultsETags are automatically generated from the response.content.ETag generation can be customized both before and after the response is rendered.The Last Modified header is automatically set from the last modified timestamp of the template.In the case of the DetailView and ListView mixins, the Last Modified header may also be
configured to get the last modification timestamp from a field on the model, in which case
the lastest of that or the template’s last modified timestamp will be used.Getting StartedFirst install django-conditional-views$pipinstalldjango-conditional-viewsThen inherit from one of the following mixins in your views:ConditionalGetMixin - Inherits from ViewConditionalGetTemplateViewMixin - Inherits from TemplateViewConditionalGetListViewMixin - Inherits from ListViewConditionalGetDetailViewMixin - Inherits from DetailViewSee theUsageandAPIsections of thedocumentationfor more details.ContributingContributions are welcome.Getting StartedTo work on the Pendulum codebase, you’ll want to clone the project locally
and install the required dependencies viapoetry.$gitclonegit@github.com:cordery/django-conditional-views.git$poetrydevelopRunning Testsdjango-conditional-views uses pytest.  To run tests:$pytest
Package: django-conditions
django-conditionsMove conditional logic that changes often from code into models so that the logic can be easily modified in admin. Some possible use cases:Segment your user base into cohorts with targeted messagingProvide different rewards to users depending on their expected valueIn a game, define the winning objectives of a mission/questand many more...InstallationFirst install thedjango-conditionspackage:pip install django-conditionsThen addconditionsto yourINSTALLED_APPSsetting:## settings.pyINSTALLED_APPS=[...'conditions',]Basic UsageStart by defining a condition in code:## condition_types.pyfromconditionsimportConditionclassFullName(Condition):# The name that appears in the db and represents your conditioncondstr='FULL_NAME'# Normal conditions define eval_bool, which takes in a user# and returns a booleandefeval_bool(self,user,**kwargs):returnbool(user.first_nameanduser.last_name)Then add a ConditionsField to your model:## models.pyfromdjango.dbimportmodelsfromconditionsimportConditionsField,conditions_from_moduleimportcondition_typesclassCampaign(models.Model):text=models.TextField()# The ConditionsField requires the definitions of all possible conditions# conditions_from_module can take an imported module and sort this out for youtarget=ConditionsField(definitions=conditions_from_module(condition_types))In the model's change form on admin, you can enter JSON to represent when you want your condition to be satisfied.{"all":["FULL_NAME"]}Now you can use the logic you created in admin to determine the outcome of an event:## views.pyfromdjango.httpimportHttpResponsefromconditionsimporteval_conditionsfrommodelsimportCampaigndefprofile(request):forcampaigninCampaign.objects.all():ifeval_conditions(campaign,'target',request.user):returnHttpReponse(campaign.text)returnHttpResponse("Nothing new to see.")Use django-conditions in your Django projects to change simple logic without having to re-deploy, and pass on the power to product managers and other non-engineers.More InformationFull documentation is availableon Read The Docs.
Package: django-confidence
=====Django Confidence=====Django Confidence is a Django app to make configuration files automatically.This app is developed to help developers create their own layout to configuration files quick and simple with built-in dictionaries or by using configuration presets (that make it even more easier).Quick start-----------1. Add "confidence" to your INSTALLED_APPS setting like this::INSTALLED_APPS = ['django.contrib.admin','django.contrib.auth',...'confidence',]2. In your settings.py import "Configuration" class from "confidence" package like this::from confidence import Configuration3. Create a dictionary of config fieldsets like this::markup = {'section': {'option': 'value'},'project': {'project_name': 'Awesome Project',}}4. In your settings.py create a variable called PROJECT_CONF and fill it with a Configuration instance::PROJECT_CONF = Configuration(filepath:str, markup:dict)4.1 Optional. You can use library of preset configuration files by importing from conf.presets. Example::from confidence import Configurationfrom confidence.presets import ProjectPreset, OptionsPresetPROJECT_CONF = Configuration.compile_from_presets(filepath, [ProjectPreset(name='Awesome Project', version='1.0', site_url='http://awesome!'),OptionsPreset(debug=True, allowed_hosts=['127.0.0.1']),])5. Run python manage.py makeconf. Configuration file will be created.6. Edit your configuration file as you want to.7. Use it in your settings.py by using get-like methods::PROJECT_NAME = PROJECT_CONF.get('project', 'project_name')DEBUG = PROJECT_CONF.get_bool('options', 'debug')ALLOWED_HOSTS = PROJECT_CONF.get_csv('options', 'allowed_hosts')8. Enjoy!
Package: django_configdir
A tool for helping with override Django configs.django_confighelper on its own creates a config for the current django
instance based on the current hostname, the current name of the
effective uid and the current directory in which the django instance
is sitting:config/hostname/euidname__dirname.pyIf the config already exists django_confighelper exits with a warning.The ‘edit’ subcommand attempts to start a system editor on the
config. It first tries the environment variable $EDITOR and then
switches to “editor” from the execution path.The ‘print’ subcommand prints the filename of the config file. This is
so you can script further interactions, for example:echo “CONFIG_SPECIAL=True” >> $(django_confighelper print)The ‘default’ subcommand looks for a default config file in
config/defaults/$user.py and if it exists, it creates a config using
the values contained there in. It opens the newly created file just
in case you need to change some values - like FRONTEND_PORT e.t.cThe ‘printval’ subcommand prints the value of a DJANGO config setting
after the config has been applied. For example:django_confighelper printval DATABASE_HOSTprints out the setting of the database host.The ‘updatesettings’ subcommand appends the contents of configdir/templates.py
to the end of the settings.py in the current directory. This is required to be
run once (and once only), and simply adds some import statements to handle
the additional import of per-instance settings files.The ‘cat’ subcommands outputs the contents of the instance specific config file
(i.e. config/hostname/euidname__dirname.py)The ‘dir’ subcommand outputs the evaluated  values of all settings managed by
django_confighelper.confignginx is also included. This is a management command you can use
to generate Nginx configs from your Django app../manage.py confignginx –port=8100 –domain=www.example.comwill generare an nginx config that will proxy requests to the port but
send all static data to the STATIC_ROOT via the STATIC_URL.
Package: django-configfield
Contentsdjango-configfieldInstallationIn your settings.pyIn your models.pyIn your forms.pyDevelopment0.2.20.2.10.2.00.1.0-beta0.1.0-alphadjango-configfieldA new model and form field flexible for schema changes. Internally is
stored as JSON field in database.InstallationIn your settings.pyINSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',

    #.....................#

    'configfield',
)In your models.pyclass MyModel(models.Model):

    .....

    config = ConfigField(verbose_name=_('Config'), null=True, blank=True)In your forms.pyclass MyForm(forms.ModelForm):

    class Meta:
        model = MyModel

    def __init__(self, *args, **kwargs):
        super(MyForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            config_dict = self.instance.config
        else:
            config_dict = MY_DEFAULT_CONFIG_DICT
        self.fields['config'].set_config_dict(config_dict)DevelopmentYou can get the last bleeding edge version of django-configfield by doing a clone
of its hg repository:hg clone https://bitbucket.org/msaelices/django-configfield0.2.2Frozen django-jsonfield version because the latest version is broken with configfield.0.2.1Fix a error, when a param of the dict was None0.2.0Add the set_config_dict functionRemove the smart_if dependenceRemove the JSONField class and use the JSONField of the django-jsonfield eggWrite a readme with an installAdd the django-jsonfield in the requeriements0.1.0-betaImproved type checking. Needed when the config field is placed in a subclass.Fix name of base template.0.1.0-alphaInitial version
Package: django-configuration
Some site wide settings belong in the database. This Django-Configure provides
a familiar way to implement this pattern. It uses django-polymorphic, mostly to
provide a clean admin interface. Any model field can be used in a
configuration, and any of the standard django admin utilities (like
permissions) can be used.InstallationInstall from pypi using your favorite method::pip install django-configurationUsageInmyapp/models.py::from configuration.models import Configuration

class MyConfiguration(Configuration):
    my_var = models.CharField(max_length=255, default='Hello!')Then elsewhere::>>> from myapp.models import MyConfiguration
>>> print MyConfiguration.objects.get()
Hello!A Configuration instance is not saved to the database untilsaveis
explicitly called or until it is saved in the admin, so it is important to
specify default values on your fields.A custom admin interface can be provided as follows::from configuration.models import Configuration
from configuration.admin import ConfigurationAdmin

class MyAdmin(ConfigurationAdmin):
    pass

class MyConfiguration(Configuration):
    my_var = models.CharField(max_length=255, default='Hello!')

    admin_class = MyAdminThe admin class must inherit fromConfigurationAdmin. The admin_class
attribute can also be given as a dotted string::class MyConfiguration(Configuration):
    my_var = models.CharField(max_length=255, default='Hello!')

    admin_class = 'myapp.admin.MyAdmin'Efficiency and CachingDjango-Configuration is quick, easy and intuitive, and allows you to follow
django patterns. However it is not the most efficient method of keeping
configuration optinos in the database. The use of django-polymorphic allows for
a great admin interface but makes queries more costly. The library currently
provides no caching - although caching apps that cache query results should
help with that.
Package: django-configurations
django-configurations eases Django project configuration by relying
on the composability of Python classes. It extends the notion of
Django’s module based settings loading with well established
object oriented programming patterns.Check out thedocumentationfor more complete examples.QuickstartInstall django-configurations:$python-mpipinstalldjango-configurationsor, alternatively, if you want to use URL-based values:$python-mpipinstalldjango-configurations[cache,database,email,search]Then subclass the includedconfigurations.Configurationclass in your
project’ssettings.pyor any other module you’re using to store the
settings constants, e.g.:# mysite/settings.pyfromconfigurationsimportConfigurationclassDev(Configuration):DEBUG=TrueSet theDJANGO_CONFIGURATIONenvironment variable to the name of the class
you just created, e.g. in bash:$exportDJANGO_CONFIGURATION=Devand theDJANGO_SETTINGS_MODULEenvironment variable to the module
import path as usual, e.g. in bash:$exportDJANGO_SETTINGS_MODULE=mysite.settingsAlternativelysupply the--configurationoption when using Django
management commands along the lines of Django’s default--settingscommand line option, e.g.$python-mmanagerunserver--settings=mysite.settings--configuration=DevTo enable Django to use your configuration you now have to modify yourmanage.py,wsgi.pyorasgi.pyscript to use django-configurations’s versions
of the appropriate starter functions, e.g. a typicalmanage.pyusing
django-configurations would look like this:#!/usr/bin/env pythonimportosimportsysif__name__=="__main__":os.environ.setdefault('DJANGO_SETTINGS_MODULE','mysite.settings')os.environ.setdefault('DJANGO_CONFIGURATION','Dev')fromconfigurations.managementimportexecute_from_command_lineexecute_from_command_line(sys.argv)Notice in line 10 we don’t use the common tooldjango.core.management.execute_from_command_linebut insteadconfigurations.management.execute_from_command_line.The same applies to yourwsgi.pyfile, e.g.:importosos.environ.setdefault('DJANGO_SETTINGS_MODULE','mysite.settings')os.environ.setdefault('DJANGO_CONFIGURATION','Dev')fromconfigurations.wsgiimportget_wsgi_applicationapplication=get_wsgi_application()Here we don’t use the defaultdjango.core.wsgi.get_wsgi_applicationfunction but insteadconfigurations.wsgi.get_wsgi_application.Or if you are not serving your app via WSGI but ASGI instead, you need to modify yourasgi.pyfile too.:importosos.environ.setdefault('DJANGO_SETTINGS_MODULE','mysite.settings')os.environ.setdefault('DJANGO_CONFIGURATION','DEV')fromconfigurations.asgiimportget_asgi_applicationapplication=get_asgi_application()That’s it! You can now use your project withmanage.pyand your favorite
WSGI/ASGI enabled server.
Package: django-configurations-autoenv
Installation$[sudo]pipinstalldjango-configurations-autoenvHow it worksenvironment variable must be prefixed withDJANGO_Truevalues:'yes','y','true','1'Falsevalues:'no','n','false','0'list values: must contain a comma,settings.pyfromconfigurationsimportConfigurationfromdjango_configurations_autoenvimportAutoenvMixinclassBase(AutoenvMixin,Configuration):fromdjango_configurations_autoenvimportAutoenvConfigurationclassBase(AutoenvConfiguration):.envDJANGO_STATIC=/static/DJANGO_ALLOWED_HOSTS=domain1.com,domain2.comDJANGO_DEBUG=falseLinksdjango-configurationsreadme42.com
Package: django-configurations-ec2
Installation$[sudo]pipinstalldjango-configurations-ec2FeaturesALLOWED_HOSTS- EC2 private ipLOGGING- CloudWatch loggingsettings.pyfromconfigurationsimportConfigurationfromdjango_configurations_ec2importAllowedHostsMixin,LoggingMixinclassProd(AllowedHostsMixin,Configuration):ALLOWED_HOSTS=['.domain.com']CloudWatchfromconfigurationsimportConfigurationfromdjango_configurations_ec2importLoggingMixinclassProd(LoggingMixin,Configuration):....envDJANGO_AWS_ACCESS_KEY_ID=ACCESS_KEY_IDDJANGO_AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEYDJANGO_AWS_REGION_NAME=REGION_NAMEDJANGO_AWS_LOG_GROUP=LOG_GROUPDJANGO_AWS_STREAM_NAME=STREAM_NAMELinksdjango-configurationsreadme42.com
Package: django-configurations-google-analytics
Installation$[sudo]pipinstalldjango-configurations-google-analyticssettings.pyfromconfigurationsimportConfigurationfromdjango_configurations_google_analyticsimportGoogleAnalyticsMixinclassBase(GoogleAnalyticsMixin,Configuration):# GA_ID = 'UA-XXXXXXXX-Y'.envDJANGO_GA_ID="UA-XXXXXXXX-Y"Templates{% load google_analytics %}
...
{% google_analytics %}Linksdjango-configurationsreadme42.com
Package: django-configurations-wsgi
Installation$[sudo]pipinstalldjango-configurations-wsgiExamplesgunicorndjango_configurations_wsgi:application-b0.0.0.0:8080requirements.txt...
django_configurations_wsgi
...P.S. defaultwsgi.py:importosos.environ.setdefault('DJANGO_SETTINGS_MODULE','settings')os.environ.setdefault('DJANGO_CONFIGURATION','Dev')fromconfigurations.wsgiimportget_wsgi_applicationapplication=get_wsgi_application()Linksdjango-configurationsreadme42.com