Saravanan666/pypi-org huggingface dataset:
Package: django-xpower
Authors:Justin Quick <justquick@gmail.com>Version:0.1pip install django-xpower==0.1.0Django X Power is a simple middleware that adds theX-Powered-Byheader to any Django site.InstallInstall the module using pip/easy_install or whatever you like then add in the middleware into yourMIDDLEWARE_CLASSES:MIDDLEWARE_CLASSES = (
    'xpower.middleware.XPoweredByMiddleware',
    ...
)ConfigureIn your settings you may define the contents of theX-Powered-Byheader:X_POWERED_BY = 'Django'If you do not set this it will use the default which is'Django/%(version)swhere%(version)sis replaced with the version of Django that you are using.TestingAn example project is provided so just run./manage.py runserverand then you can
confirm that it is working by runningcurl-ihttp://localhost:8000| head.
You should see something like this:HTTP/1.0 200 OK
Date: Wed, 07 Jul 2010 15:40:59 GMT
Server: WSGIServer/0.1 Python/2.6.1
Content-Type: text/html
X-Powered-By: Django/1.2.1 SVN-13336AlternatesSome alternatives for the header contents:Ponies with magical powersWho the fuck knowsA series of tubesPerfectionists with deadlinesOpinionated developers
Package: django-xprez
Django XprezXprez is CMS For DjangoQuick startInstall django-xprez:pip install django-xprezAdd following apps to your settings.INSTALLED_APPS:INSTALLED_APPS = [
        ...
        'django.contrib.humanize',
        'sorl.thumbnail',
        'xprez',
        'xprez.ck_editor',
        ...
    ]Runpython manage.py migrateto create xprez models.Make sure request context processor is enabled in settings:TEMPLATES = [
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'django.template.context_processors.request',
                ...
            ]
        },
        ...
    ]Include the xprez admin URLconf in your project urls.py like this:path('xprez/', include('xprez.urls')),Create models:from xprez.models import ContentsContainer

    class Page(ContentsContainer):
        title = models.CharField(max_length=255)
        slug = models.SlugField(max_length=255, unique=True)

        def __str__(self):
            return self.titleRegister models in admin:from django.contrib import admin
    from xprez.admin import XprezAdmin
    from .models import Page

    @admin.register(Page)
    class PageAdmin(XprezAdmin):
        passRender page in template:{% load xprez %}
    {% xprez_front_media %}
    {% include 'xprez/includes/photoswipe.html' %}
    {% include 'xprez/container.html' with contents=page.contents.all %}(optional) Change sorl thumbnail backend in settings - for seo-friendly thumbnail filenames:THUMBNAIL_BACKEND = 'xprez.contrib.sorl_thumbnail.thumbnail_backend.NamingThumbnailBackend'(optional) Look at example_app for more comprehensive example.DevelopmentTo setup automated black formatting connected to git commits:installpre-commitrunpre-commit installTo rebuild ckeditor:cd xprez/ck_editor/assets/ckeditor5
npm install
npm run buildTo rebuild css stylescd xprez/static/xprez
npm install
npm run build (or `watch` for developing)Deploying new versionhttps://github.com/s-cape/django_xprez/actions/workflows/release.ymlTODOadd custom module tutorial to Readmefix template content to save only relative path to databasecheck template content raising UnicodeDecodeErrorcreate manual for various situations (ck_editor branch)using custom config and implement style sources into own building system (using get_module_path.py)how to implementxprezanchorfunctionality
Package: django-x-robots-tag-middleware
Django X-Robots-Tag MiddlewareSimple Django middleware to use theX-Robots-Tagheader based on a config param.InstallationFrompypi <https://pypi.python.org>$ pip install django-x-robots-tag-middlewareUsageAdd'x_robots_middleware.XRobotsMiddleware',to your middleware list in settings.py.AddX_ROBOTS_TAG = ['noindex','nofollow']to your settings.py with the settings you want for the X_ROBOTS_TAG.Details about the values for the tag and what they do can be foundin the Google Documentation <https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag?hl=en#using-the-x-robots-tag-http-header>_.
Package: django-xross
https://github.com/idlesign/django-xrossDescriptionReusable application for Django nicely bridging client and server sides.Streamline you server and client interaction using some declarative techniques in your HTML,
and a couple of xross functions in your views.Somewhere in yourviews.py:fromdjango.shortcutsimportrenderfromxross.toolboximportxross_view,xross_listener# That's all we need from xross.deflist_news(request):"""This function will be used by xross to load news using AJAX."""news=...# Here we fetch some news from DB.returnrender(request,'mytemplates/sub_news.html',{'news':news})@xross_view(list_news)# Decorate your view - instruct xross to use `list_news` when needed.defindex_page(request):"""This is our view to streamline."""xross_listener()# xross will handle AJAX calls from that moment.returnrender(request,'mytemplates/index.html')Now to yourmytemplates/index.html:<!DOCTYPE html><html><head><!-- xross depends on jQuery. Include it. --><scriptsrc="http://yandex.st/jquery/2.1.1/jquery.min.js"></script><!-- Now xross itself. --><scriptsrc="{{ STATIC_URL }}js/xross/xross.min.js"></script><scripttype="text/javascript">xross.automate();// Instruct xross to watch for page elements with `xross` class.</script></head><body><divid="list_news"class="xross"><!--
            Contents of this div will be replaced with news from Django's `list_news()`
            automatically on page load.

            That's the default of xross, but it knows some other nice little tricks.
            Read the docs.
         --></div></body></html>At lastmytemplates/sub_news.html(nothing special):{% for item in news %}<div><div>{{ item.title }}</div><div>{{ item.text }}</div></div>{% endfor %}That’s not all, not at all. Read the docs!Documentationhttp://django-xross.readthedocs.org/
Package: django-xss-cleaner
django-xss-cleaner 是一个基于 bleach 的 django XSSFilter 工具，实现了对 GET 和 POST 请求参数的 XSS 白名单过滤功能。包中内置了部分白名单 HTML 标签、属性设置，同时也支持自定义扩展。settings.py 安装和配置说明安装中间件添加中间件 “xss_cleaner.middlewares.CleanXssMiddleware” 到 settings 中MIDDLEWARE_CLASSES = (
   'xss_cleaner.middlewares.CleanXssMiddleware',
   ...
)建议将 CleanXssMiddleware 尽量的靠前放置，最好是第一个。这是为了保证后端获取的数据都通过了 XSS 过滤，避免 XSS 向量被注入。[可选]配置Clean XSS级别默认配置为 ‘HIGHT’，可选参数：[‘LOW’, ‘HIGH’]XSS_LEVEL = 'HIGH'如果设置为 ‘HIGHT’ ，允许的标签和属性为{
    'tags': ['a', 'img', 'strong', 'p', 'div', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'table', 'ul', 'ol', 'tr', 'th', 'td', 'li'],
    'attributes': {'a': ['href', 'title', 'target'], 'img': ['width', 'height', 'src']},
    'styles': [],
    'strip': False,
    'strip_comments': False
}如果设置为 ‘LOW’ ，允许的标签和属性为{
    'tags': ['a', 'img', 'br', 'strong', 'b', 'code', 'pre', 'p', 'div', 'em', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'table', 'ul', 'ol', 'tr', 'th', 'td', 'hr', 'li', 'u'],
    'attributes': {'a': ['href', 'title', 'target'], 'img': ['width', 'height', 'src', 'alt'],
              '*': ['class', 'style']},
    'styles': [],
    'strip': False,
    'strip_comments': False
}参数的含义，在下面会有介绍。[可选]自定义新增白名单增量式添加新的标签和属性到白名单。BLEACH_WHITE_LIST = {
    'tags': [],
    'attributes': {},
    'styles': [],
    'strip': False,
    'strip_comments': False
}参数说明：tags (list)  – 允许的标签，不在白名单的标签被转义attributes (dict)  – 允许的属性，不在白名单的属性被删除styles (list) – 允许的样式，不在白名单的样式被删除strip (bool) – 是否剔除转义后的字符strip_comments (bool) – 是否剔除 HTML commentsBLEACH_WHITE_LIST 中的标签、属性、样式，将会以增量的形式增加在 Clean XSS 级别允许的白名单上。如果设置了 strip、strip_comments ，将覆盖默认设置。[可选]是否打印或记录转义为了方便调试，记录 XSS Filter 的信息，提供一个开关:BLEACH_SHOW = True默认值为 True，可选值为 [True ，False]如果是本地开发，转换日志将直接 print 在 Console。如果是线上，将打印为 warning  日志。xss_cleaner 豁免装饰器xss_cleaner 包提供了两个装饰器，用于豁免 XSS Filter 处理。escape_clean，提供 View 级别的豁免。from cleanxss.decorators import escape_clean
 @escape_clean
 def home(request):
    passescape_clean_param，提供参数级别的豁免。from cleanxss.decorators import escape_clean_param
 @escape_clean_param('param1', 'param2')
 def home(request):
    passxss_cleaner 处理示例下面使用的是默认配置： XSS_LEVEL= ‘HIGH’转义非白名单标签
XSS Clean: Transfer  <b><i>an example</i></b>  To  &lt;b&gt;&lt;i&gt;an example&lt;/i&gt;&lt;/b&gt;

 删除非白名单样式
XSS Clean: Transfer  <p class="foo" style="color: red; font-weight: bold;">blah blah blah</p>  To  <p>blah blah blah</p>

 删除非白名单属性
XSS Clean: Transfer  <img click="de"  alt="an example" width=500>  To  <img width="500">

 自动补全，规范化 HTML
XSS Clean: Transfer  <a href=http://abc.com>my text; a b b  To  <a href="http://abc.com">my text; a b b</a>下面使用的是默认配置： XSS_LEVEL= LOW’转义非白名单标签
XSS Clean: Transfer  <b><i>an example</i></b>  To  <b>&lt;i&gt;an example&lt;/i&gt;</b>

删除非白名单样式
XSS Clean: Transfer  <p class="foo" style="color: red; font-weight: bold;">blah blah blah</p>  To  <p class="foo" style="">blah blah blah</p>

删除非白名单属性
XSS Clean: Transfer  <img click="de"  alt="an example" width=500>  To  <img alt="an example" width="500">

自动补全，规范化 HTML
XSS Clean: Transfer  <a href=http://abc.com>my text; a b b  To  <a href="http://abc.com">my text; a b b</a>
Package: django-xss-detection
# django xss detectionThis package contains a django template parser that can be used to find templatesthat contain variables that will not be escaped. This package currently hasno knowledge of custom filters, custom tags, and python code (e.g. uses ofmark safe). The code has only been tested against django versions >= 1.5 and <= 1.7.## Requirements* django >= 1.5 and < 1.8* lxml## UsageThis package can be used on the command line by running> `python -m django_xss_detection.cli`## How does it work?The code works by monkey patching django template code and providing througha callback function to VariableNode that ends up referring to the`CompileStringWrapper.handle_callback` method. The callback function is usedlater when the code `renders` a given template and encounters a variable nodethat will not be escaped. The implementation of detecting unquoted variable nodesin element attributes and variable nodes in a javascript context lackingjavascript escaping are not implemented through callbacks, see`get_non_quoted_attr_vars_for_template` and`get_non_js_escaped_results_for_template` in parse_template.py respectively.Additionally, the code has modified versions of built in conditional tags,such as `{% if %}` and `{% ifequal %}`, so as to `render` all possible templatecode. If this package does not work on your custom template tags thenyou can add support for them similar to how `waffle` template tags areimplemented (see `templatetags/waffle.py` and the `patch` method in `util.py`).
Package: django-xss-protector
django_xss_protectordjago xss protector is a Python library for filtering incomming requests with malformed data in view levelInstallationUse the package managerpipto install django_xss_protector.pipinstalldjango_xss_protectorimport it in your viewfromxss_protector.decoratorimportxss_protectorfilter all@xss_protector()defmy_view(reqeust):....this will check everything, the url parameters, url querystring, request body and form data for possible xss datafilter some keys@xss_protector("key1","key2","key3")defmy_view(reqeust):....this will check the url parameters, url querystring, request body and form data for possible xss data but only in the mentioned keysexclude some keys@xss_protector(lst_excluding_keys=["key1","key2"])defmy_view(reqeust):....this will check the url parameters, url querystring, request body and form data for possible xss data but not in the mentioned keyscustome response@xss_protector(response_on_error=JsonResponse({"ERROR":"custome error"})defmy_view(reqeust):....ContributingPull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMIT
Package: django-xss-shield
## Badges[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)# XSS ShieldThe primary objective of xss shield is to find the possible xss attack and block the request or return None.
As xss is one the most common bug in web applications security researchers a finding ways to prevent it and hackers are creating more advanced payloads. most modern frameworks prevents xss by escaping special characters but still xss can be found.
as react and djangos jinja2 tamplate engine does escapes the special characters
but injecting user inputs in href attr {{ }} can be possible to exploit xss.## UsagesYou can use the shield as a middleware by adding it into the settings.py middleware listMIDDLEWARE = [‘shield.middleware.XssShieldMiddleware’,]Or you can use it as filter to where you want to senitize{% load shield_tag %}it has two filters one to senitize the value for not injecting as javascript: or data: URI variables{{ data|protect }}The other process bruteforcess through a list of event handlers which is possible to lead into xss{{ data|bruter }}Thats much simple it is :)
Package: django-xstatic
UseXStaticpackages and DjangoStaticFilesto manage your static
files like jQuery.Why?Managing static files is a PAIN, You must download them, unpack them copy them,
keep them up to date …
Wouldn’t it be cool if you cool justpip installthem?What does it do?django-xstaticmakes the static files from xstatic packages installed inINSTALLED_APPSbe collected by./manage.py collectstatic.Installation and usageInstall django-xstaticAdd'django_xstatic.finders.XStaticFinder'to yourSTATICFILES_FINDERSInstall your xstatic packages and add them toINSTALLED_APPSRun./manage.py collectstaticOpen questionsdjango-xstatic detects xstatic package when they are in theINSTALLED_APPSlist. Should it uses its own settings key?What it should (maybe) do, but doesn’t yetIn the current version, you still have to remember the names of the javascript
file names, but wouldn’t you like to have only this in your templates:<head>
{% xstatic jquery %}
{% xstatic jquery.autocomplete %}
</head>xstatic packages comes with a metadata value namedLOCATIONS, giving URLs of
CDN serving these same static files, django-xstatic should give a template tag
to use them easily.Bonus FeatureIt works withdjango-compressor!
Package: django-xvalidate
django-xvalidate allows you to declare cross-field validators within a
Django model.As an example, consider a Django model namedEvent.fromdjango.dbimportmodelsclassEvent(models.Model):title=models.CharField(max_length=255)start_date=models.DateField()end_date=models.DateField()django-xvalidate allows you to declare that the start date precedes the end
date as follows:fromdjango.dbimportmodelsfromxvalidateimportXValidatedModel,XLeclassEvent(XValidatedModel,models.Model):title=models.CharField(max_length=255)start_date=models.DateField()end_date=models.DateField()classXVMeta(XValidatedModel.XVMeta):spec=[XLe('start_date','end_date').message('The start date should precede the end date')]XValidatedModelensures that this specification is maintained
invokingEvent.clean()and raisesValidationErroras
appropriate.Why use django-xvalidate?django-xvalidate allows you to specify how to validate your model instances
in a more declarative manner than writing imperative code within yourclean()methods. Without django-xvalidate you would have to
implement the above example asdefclean(self):super(Event,self).clean()if(self.start_dateisnotNone)and(self.end_dateisnotNone):if(self.end_date<self.start_date):raiseValidationError('The start date should precede the end date')With a more declarative format we have the option at some point in the
future to automate the creation of test data that passes (or fails)
validation.django-xvalidate comes some operator overloading that brings syntactic
sugar to your declarations making them very easy to read. For instance,
you could specify:((XF('end_date')-'start_date')>datetime.timedelta(days=4)).message('Event should last at least 5 days')django-xvalidate also allows the use of Django’s double-underscore (__)
syntax to dereference related objects, enabling succinct definitions such
as the following(XF('registration_date')<='event__end_date').message('Must register before the event ends')
Package: django-xworkflows
UseXWorkflowsalong with Django models.Django-XWorkflows allow to bind a Django model to a workflow, with a few extra features:Auto-save after transitionsLog each action into the databaseDefine a workflow and add it to a model:fromdjangoimportmodelsfromdjango_xworkflowsimportmodelsasxwf_modelsclassMyWorkflow(xwf_models.Workflow):states=(('new',_(u"New")),('old',_(u"Old")),)transitions=(('get_old','new','old'),)initial_state='new'classMyModel(xwf_models.WorkflowEnabled,models.Model):state=xwf_models.StateField(MyWorkflow)Use the workflow:>>>obj=MyModel()>>>obj.state# Defaults to the initial_stateState('new')>>># Perform a transition>>>obj.get_old()>>>obj.stateState('old')>>># Object was saved to the database>>>obj.pk1>>># Logs were saved to the database>>>xwf_models.TransitionLog.objects.all()[TransitionLog(MyModel:new->oldat2012-04-14T12:10:00+0200)]LinksPackage on PyPI:http://pypi.python.org/pypi/django-xworkflowsRepository and issues on GitHub:http://github.com/rbarrois/django_xworkflowsDoc onhttps://django-xworkflows.readthedocs.io/XWorkflows on GitHub:http://github.com/rbarrois/xworkflows
Package: django-xworkflows-3
UseXWorkflowsalong with Django models.Django-XWorkflows allow to bind a Django model to a workflow, with a few extra features:Auto-save after transitionsLog each action into the databaseDefine a workflow and add it to a model:fromdjangoimportmodelsfromdjango_xworkflowsimportmodelsasxwf_modelsclassMyWorkflow(xwf_models.Workflow):states=(('new',_(u"New")),('old',_(u"Old")),)transitions=(('get_old','new','old'),)initial_state='new'classMyModel(xwf_models.WorkflowEnabled,models.Model):state=xwf_models.StateField(MyWorkflow)Use the workflow:>>>obj=MyModel()>>>obj.state# Defaults to the initial_stateState('new')>>># Perform a transition>>>obj.get_old()>>>obj.stateState('old')>>># Object was saved to the database>>>obj.pk1>>># Logs were saved to the database>>>xwf_models.TransitionLog.objects.all()[TransitionLog(MyModel:new->oldat2012-04-14T12:10:00+0200)]LinksPackage on PyPI:http://pypi.python.org/pypi/django-xworkflowsRepository and issues on GitHub:http://github.com/rbarrois/django_xworkflowsDoc onhttps://django-xworkflows.readthedocs.io/XWorkflows on GitHub:http://github.com/rbarrois/xworkflows
Package: django-yabackup
YaBackup========YaBackup is a simple Django app to backup your files and database to Yandex.DiskRequirements------------Python >= 3Django >= 1.11YaDiskClient >= 0.4.5Older versions might work tooInstall-------`pip install django-yabackup`Quick start-----------1. Add "YaBackup" to your INSTALLED_APPS setting like this:INSTALLED_APPS = [...'YaBackup',]2. Add YABACKUP_SETTINGS to your project settings:YABACKUP_SETTINGS = {'DATE_TIME_FORMAT': '%Y-%m-%d_%H-%M-%S',  # Will be added to your backup file name'YADISK_LOGIN': 'login',                  # Yandex.Disk login'YADISK_PASSWORD': 'password',            # Yandex.Disk password'YADISK_BACKUP_ROOT': '/BACKUPS/',        # path to your backups folder at Yandex.Disk MUST BE CREATED BEFORE RUNNING BACKUPS}3. Run `python manage.py migrate` to create the YaBackup models.Usage-----You can create and run your backups from the admin backend. Also, you can run them with management command:`python manage.py YaBackup`Cron----You can use Chroniker (https://github.com/chrisspen/django-chroniker)or other apps to schedule your backups by running management command.
Package: django-yabl
django-yablYet another bookmarking library (yabl) for Django. Bookmark and tag arbitrary models.AbstractBookmarkablecontainsbookmarksfield. This enables arbitrary child models, e.g. Movies, Books, Laws, Clothes, etc., to inherit uniform properties for bookmarking and tagging.Thebookmarksfield is mapped to a genericBookmarkmodel containing:the authenticated user adding the bookmark, i.e. thebookmarker;the concrete model instance referenced, i.e. thebookmarked;[^1] anda ManyToManytagsfield which maps to aTagItemmodel.[^1]: The model is referenced via acontent_typeand anobject_idAbstractBookmarkableThe abstraction makes each inheriting instancebookmarkableandtaggableby authenticated users.AttributesPurposeis_bookmarked(user)Check whether object instance is bookmarked or notget_bookmarked(user)Get instances of model that user has bookmarkedget_user_tags(user)If user bookmarked, get user-made tags on instancetoggle_bookmark(user)Toggle bookmark status as bookmarked or notadd_tags(user, tags: list[str])Add unique tags, accepts a list of namesremove_tag(user, tag: str)Delete an existing tag name from tags previously addedset_bookmarked_context(user)Combines relevant urls and attributes for template output@modalCustom modal enables:toggle,add tags,remove tag@launch_modal_urlURL to launch custom modal@get_item_urlURL to load the panel containde within custom modal@add_tags_urlURL to POST tags added@del_tag_urlURL to DELETE tag added@toggle_status_urlURL to toggle bookmark status of an object instance added@object_content_for_panelContent when custom modal is loaded;mustbe overridenModal-based UXWhat is the concept?The modal is where the user interacts – i.e. toggle bookmark status, add tags, remove tag (see table above) – with the data.How is the modal styled?See the htmx/hyperscript examplemodal.css.How is the modal constructed during run-time?Seeapp-levelmodal.htmlwhich shows a modal via htmx click on the@launch_modal_urlproperty.What are the pre-made contents of the modal?Theapp-levelpanel.html, contained within the modal, shows an actionable form for saving the bookmarable object and associating said object with tags:The submission of tags is POST'ed through theadd_tags_url.The deletion of tags is DELETE'ed through thedel_tag_url.The bookmark toggle is PUT'ed through thetoggle_status_url.SetupDownload andinstall.Seeconfigurationof models to be bookmarked and tagged.Examinefrontendsetup usinghtmx/hyperscript.
Package: django-yacaptcha
=====Django YaCaptcha=====Django YaCaptcha - Yandex Captcha (cleanweb) form field/widget integration app.Uses https://github.com/coagulant/cleanwebQuick start-----------1. Add "yacaptcha" to your INSTALLED_APPS setting like this:<pre>INSTALLED_APPS = ('yacaptcha',)</pre>2. Get the API key http://api.yandex.ru/cleanweb and add to your project settings:<pre>YACAPTCHA_KEY = 'your_api_key'</pre>3. Add YaCaptchaField in your form like this::<pre>from yacaptcha.fields import YaCaptchaFieldclass TestForm(forms.Form):name = forms.CharField()captcha = YaCaptchaField()</pre>4. Add form field widget templateYou may create your own template for field widget. For this add in project settings:<pre>YACAPTCHA_WIDGET_TEMPLATE = 'path_to_widget.html'</pre>Or use default widget.html from package django-yacaptcha/templates/yacaptcha/widget.html5. If you use django-registration, you may use registartion backend with yacaptcha field like this:<pre>url(r'^accounts/', include('yacaptcha.backends.default.urls')), # yacaptcha backend for registration form(r'^accounts/', include('registration.backends.default.urls')),</pre>