Saravanan666/pypi-org huggingface dataset:
Package: django-pre-post
[![Build Status](https://travis-ci.org/CSDTs/Django-pre-post.svg?branch=master)](https://travis-ci.org/CSDTs/Django-pre-post)[![Updates](https://pyup.io/repos/github/CSDTs/Django-pre-post/shield.svg)](https://pyup.io/repos/github/CSDTs/Django-pre-post/)# Django-pre-postThis Django app provides the ability to create pre-post questions and answers. It was developed by the CSDTs team at RPI to embed pre-post tests for students in their website and to ease data collection.# Installation & Integration## Download and install:Either use pip in terminal: `pip install django_pre_post`Or add django_pre_post to your requirements / libraries file and run `pip install -r requirements.txt`## Add the application to your site:Include it in settings.py```INSTALLED_APPS = (... your apps here ...'django_pre_post',)```Include it in URLS.py```urlpatterns = [... your pages here...url(r'^questionnaire/', include('django_pre_post.urls')),]```# Testing## Prerequisites* VirtualBox* Linux: sudo apt-get install virtualbox* Windows & Mac: https://www.virtualbox.org/wiki/Downloads* Vagrant* Linux: sudo apt-get install vagrant* Windows & Mac: https://www.vagrantup.com/downloads.html* Git* Linux: sudo apt-get install git* Windows & Mac: https://git-scm.com/downloads* For windows Make sure C:\Program Files\Git\usr\bin [is in your path variable](http://www.computerhope.com/issues/ch000549.htm)## Setup```shellgit clone https://github.com/CSnap/Django-pre-post #get the codecd Django-pre-postvagrant up #build the system in a virtual machinevagrant ssh #enter the virtual machinecd /vagrantpython manage.py runserver 0.0.0.0:8000  #run the server```Navigate to localhost:8002/admin/
Package: django-presentable-exception
Presentable ExceptionsThis is a module for django restframework, in which modules can specifiy exceptions in an
extra file with an key an description. At some place in the code, they can be fetched by
the package and key and bubble up to the view. Here a mixin detects them and creates a
proper response for an fat-client, which can show them then to to user - thus the exceptions
are presentable.Getting startedSay, you have a module, likeauth_apiwhich is registered inINSTALLED_APPSin the Djangosettings.py. Create a new fileauth_api/presentable_exceptions.pywith this contentpresentable_exceptions={'client':[('not-enough-data-to-delete-user','You did not provide enough data, that we can delete the user{username}')],'server':[('backend-connection-lost','We lost the connection to the backend'),]}This file can be in every module and consists of two parts: The exceptions, that are the clients
fault and the exceptions that are our fault. The first will cause a 4xx error, the latter a 5xx.Say, you have now an View somewhere, like that:classMeView(WithPresentableException,APIView):defget(self,request):data=some_function_with_a_deep_call_stack()returnResponse(data)This will call multiple function and somewhere there is the functionboom()called:defboom():raisePresentableException.of('auth_api','backend-connection-lost')defsome_function_with_a_deep_call_stack():# ...boom()# ...ThisPresentableExceptionwill be anPresentableServerExceptionand bubble up into
the MixingWithPresentableExceptionspecified in the view above, which generates
a proper response (with a 5xx code in this case).
Package: django-press
ブログを作れるモジュールの開発作成日：20191118更新日：20191118目的ワードプレスというサービス？ソフトウェア？がある。
これは簡単にサイトやブログを作れるようにするためのものであり、PHPという言語で書かれている。
一切プログラムを書かなくてもいい感じのサイトが作れる。Pythonでもwebサイトを作れるライブラリーは存在するが、ワードプレス程簡単ではない。
簡単なブログなら一切コードを書かなくていいようなテンプレートモジュールがあってもいいのではないかと思い、開発しようと思った。具体的にイメージは上のワードプレスをPythonで再現する感じである。
基本的にGUI操作のみでブログの作成を行えるようにする。使おうと思っているライブラリー・Django
webサイトを開発するためのライブラリーで、個人で使用経験もあるので採用する。目標！コマンド1つ打てばサイトが構築される！例：pysite create-> サイトが作られる！要件コア設定をLive編集できる。ブログが書ける
Package: django-presskit
django-presskitA port of Rami Ismail'spresskit()/dopresskitto Django.InstallingRequirements:Django>=2.2django-filer>=2.0.2easy_thumbnails>=2.7.1Markdown>=2.6.11Pillow>=7.1.0django-admin-sortable2>=0.7.7future>=0.18.2ConfiguringAdd "django_presskit" and "adminsortable2" to your settings.py INSTALLED_APPS.AddDJANGO_PRESSKIT_DEFAULT_COMPANY_ID = 1to your settings file.In your main urls.py, add a line like:url(r'^presskit/', include('django_presskit.urls', namespace='django_presskit')),All data can be set up in the Django admin.UpgradingIf upgrading to 1.1.0, run the following on your project after addingadminsortable2to your settings:python manage.py reorder django_presskit.additionallink django_presskit.award django_presskit.companyimageattachment django_presskit.companylogoattachment django_presskit.companyvideo django_presskit.contact django_presskit.credit django_presskit.feature django_presskit.platform django_presskit.price django_presskit.project django_presskit.projectimageattachment django_presskit.projectlogoattachment django_presskit.quote django_presskit.social django_presskit.trailerConverting from presskit()/dopresskitIf you are switching from Rami Ismail's presskit(), you'll want to make sure any old URLs that are floating around continue to work. Presskit() URLs look like/presskit/sheet.php?p=exploit_zero_day. You'll want to convert those into something like/presskit/exploit-zero-day/.Make sure that the slugs for your django-presskit projects match those for your presskit() projects. Then, you can use URL rewriting to redirect users to the new URL.If you have Apache with mod_rewrite enabled, add something like the following to your.htaccessfile:RewriteEngine  on
RewriteCond %{QUERY_STRING} ^p=(.*)$
RewriteRule "^/?presskit/sheet.php"  "/presskit/projects/%1" [N]
# Repeatedly remove underscores until only one is left.
RewriteRule "^(/?presskit/projects/.*)_(.*_.*)$"  "$1-$2" [N]
# Redirect with the last underscore rewrite.
RewriteRule "^(/?presskit/projects/.*)_(.*)$"  "$1-$2" [R=301]
RewriteRule "^/?presskit/sheet\.php$ "              "/presskit/" [R=301]If you're using nginx for rewrites, this would look like:location ~* /presskit/sheet.php {
    if ($args ~* "^p=(\d+)") {
        set $proj $1;
        set $args '';
        rewrite ^.*$ /presskit/projects/$proj permanent;
    }
}
# Remove up to 10 underscores until none are left.
rewrite ^(/?presskit/projects/.*?)_(.*)$  $1-$2 last
rewrite ^/?presskit/sheet\.php$           /presskit/ permanentIf you're using nginx and one of your slugs has more than ten underscores, add a rewrite above the first one to manually fix that one case. Nginx does not want to loop more than 10 times in a rewrite calculation.Changelog1.3.1Upgrade packages1.3.0Add support for Django 2 and 3, drop support for Django 11.2.0Upgrade to support Python 3.6+Bump to Pillow 6.2.0Bump to Django 1.11.23ContributingWhen submitting issues or pull requests, please adhere to ourCode of Conduct.
Package: django-pressroom
PressroomSimple article management for the Django web framework.Installation============Offical releases are available from http://pypi.python.org/pypieasy_install django-pressroomTracking the Development Version--------------------------------The current development version of Pressroom can be checked out via Subversion from the project site using the following command:svn checkout https://django-pressroom.googlecode.com/svn/trunk django-pressroomIf you wish to contribute to pressroom, here is how to set up your development environmentcd django-pressroomvirtualenv . --no-site-packagessource bin/activatepython bootstrap.pybin/buildout -vbin/django syncdbbin/django runserverbrowse to http://localhost:8000/Configure Your Django Settings------------------------------Add 'pressroom' to your INSTALLED_APPS setting:INSTALLED_APPS = (# ...other installed applications,'photologue','pressroom',)*** Confirm that your MEDIA_ROOT and MEDIA_URL settings are correct. ***Sync Your Database------------------Run the Django 'syncdb' command to create the appropriate tables.Instant Pressroom---------------------To use the included pressroom templates and views you need to first add pressroom to your projects urls.py file.Note: django-photologue (http://code.google.com/p/django-photologue/) is a dependancy of pressroom# urls.py:urlpatterns += patterns('',(r'^admin/(.*)', admin.site.root),(r'^pressroom/', include('pressroom.urls')),(r'^photologue/', include('photologue.urls')),)
Package: django-pretty-response
django-pretty-responseThis is a simple middleware in Django that creates clean-formatted responses, covering cases where Django and DRF are used to respond with API calls.😄 Success{"ok":true,"result":{"your_defined_data":"value"}}😢 Failure{"ok":false"error":{"status_code":"HTTP Status Code","code":"Defined Error Code (Only supported in DRF)","message":"Detailed information about the error"}}UsageAdddjango_pretty_response.middleware.ResponseMiddlewareto the end your MIDDLEWARE in settings.py.MIDDLEWARE=["django.middleware.security.SecurityMiddleware","django.contrib.sessions.middleware.SessionMiddleware","django.middleware.common.CommonMiddleware",..."django_pretty_response.middleware.ResponseMiddleware"# Add this line!]ExamplesDjango Onlyfromdjango.httpimportHttpResponsedefping(request,*args,**kwargs):returnHttpResponse("pong")returns{"ok":true,"result":"pong"}fromdjango.httpimportHttpResponsedefping(request,*args,**kwargs):returnHttpResponse("not found",status=404)returns{"ok":false"error":{"status_code":404,"message":"not found"}}fromdjango.httpimportHttpResponseBadRequestdefping(request,*args,**kwargs):returnHttpResponseBadRequest("invalid parameter")returns{"ok":false"error":{"status_code":400,"message":"invalid parameter"}}DRFfromrest_framework.responseimportResponsefromrest_framework.decoratorsimportapi_view@api_view(['GET'])defping(request,*args,**kwargs):returnResponse("pong")returns{"ok":true,"result":"pong"}fromrest_framework.responseimportResponsefromrest_framework.decoratorsimportapi_viewfromrest_framework.exceptionsimportValidationError@api_view(['GET'])defping(request,*args,**kwargs):raiseValidationError(detail="check your parameters",code="invalid value")returns{"ok":false"error":{"status_code":400,"code":"invalid value","message":"check your parameter"}}You can also customize your error fields.fromrest_framework.responseimportResponsefromrest_framework.decoratorsimportapi_view@api_view(['GET'])defping(request,*args,**kwargs):returnResponse({"hint":"check your parameters"},status=400)returns{"ok":false"error":{"status_code":400,"hint":"check your parameters"}}
Package: django-pretty-times
Almost all of this was borrowed from the py-pretty library,
tested then refactored.py-pretty Functionaility>>> from datetime import datetime, timedelta
>>> from pretty_times import pretty
>>> now = datetime.now()
>>> pretty.date(now)
'now'
>>> pretty.date(now - timedelta(seconds=30))
'30 seconds ago'
>>> pretty.date(now + timedelta(seconds=31))
'in 30 seconds'
>>> pretty.date(now - timedelta(minutes=1))
'a minute ago'
>>> pretty.date(now + timedelta(minutes=1, seconds=1))
'in a minute'
>>> pretty.date(now - timedelta(hours=1))
'an hour ago'
>>> pretty.date(now + timedelta(hours=1, seconds=1))
'in an hour'
>>> pretty.date(now - timedelta(days=1))
'yesterday'
>>> pretty.date(now + timedelta(days=1, seconds=1))
'tomorrow'
>>> pretty.date(now - timedelta(days=2))
'2 days ago'
>>> pretty.date(now + timedelta(days=2, seconds=1))
'in 2 days'
>>> pretty.date(now - timedelta(days=9))
'last week'
>>> pretty.date(now + timedelta(days=9, seconds=1))
'next week'
>>> pretty.date(now - timedelta(days=16))
'2 weeks ago'
>>> pretty.date(now + timedelta(days=16, seconds=1))
'in 2 weeks'
>>> pretty.date(now - timedelta(days=32))
'last month'
>>> pretty.date(now + timedelta(days=32, seconds=1))
'next month'
>>> pretty.date(now - timedelta(days=64))
'2 months ago'
>>> pretty.date(now + timedelta(days=64, seconds=1))
'in 2 months'
>>> pretty.date(now - timedelta(days=367))
'last year'
>>> pretty.date(now + timedelta(days=367, seconds=1))
'next year'
>>> pretty.date(now - timedelta(days=735))
'2 years ago'
>>> pretty.date(now + timedelta(days=735, seconds=1))
'in 2 years'Django Integration{% load prettytimes_tags %}
{{ my_datetime|relative_time }}
Package: django-preventconcurrentlogins
Django middleware that prevents multiple concurrent logins. If a user is already logged into the Django application and
tries to log in somewhere else, the previous session is deleted.This package is based on code fromhttp://stackoverflow.com/a/1814797andhttps://gist.github.com/peterdemin/5829440.UsageAdd “preventconcurrentlogins” to your INSTALLED_APPS settings like this:```python
    INSTALLED_APPS = {
        ...
            'preventconcurrentlogins',
    }
```Add “preventconcurrentlogins.middleware.PreventConcurrentLoginsMiddleware” to MIDDLEWARE_CLASSES:```python
    MIDDLEWARE_CLASSES = {
        ...
            'preventconcurrentlogins.middleware.PreventConcurrentLoginsMiddleware',
    }
```3. Runpython manage.py migrateto create the visitor model that is used to track a users currently active session
key.
Package: django_price
ABOUTdjango_price is an attempt to implement price representation in django, the
right way. Prices itself are very easy to implement, but may be done very
wrong if it comes to do calculations including tax.django_price features a Price class to represent net/tax/gross prices. This
class may be added, multiplied, … like you would some “simple decimal”
expect to behave. Internaly however it keeps track of all applied taxes
and its corresponsing net/tax/groos amounts. So adding two prices to
calculate the total of - for example - an invoice does not loose important
information (like which tax amounts are included).WHYAs said above price calculation can go terribly wrong. This even happens for
big players like Magento (10€ product + 5€ shipping = 15.01€ for 19% tax).
django_price tries to do things right, to avoid such issues.FEATURESBasic calculation for prices (including tax information)Knows the used currency (for rounding and formatting)Stores taxes to your database (LinearTax and Multitax)Proper rounding for prices (on demand, based on used currency)Utilities to:
- Store prices to the database
- Round prices based on the used currencyROUNDINGdjango_price does implicid rounding when calculating the net/gross/tax amount
of prices. In addition the raw, precise values are stored. So when you calculate
with prices this is always done using the precise prices, afterwards the rounded
results are recalculated.If yoou need prices to stay stable (10 times 100 should be exactly 1000) you may
need to do explicid rounding.REQUIREMENTSDjango (obviously)django_deferred_polymorph (may be skipped if you don’t use the supplied models)
Package: django-price-level
Adds time limited price levels to your model class.DocumentationThe full documentation is athttps://django-price-level.readthedocs.io.QuickstartInstall django-price-level:pip install django-price-levelAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'price_level',...)Configure in your settings the desired model:frommodel_utilsimportChoicesPRICE_LEVEL_MODEL='your.Model'PRICE_LEVEL_CATEGORY_CHOICES=Choices(('basic',_('Basic')),('company',_('For companies')))PRICE_LEVEL_CATEGORY_DEFAULT='basic'Add author middleware in settings:MIDDLEWARE_CLASSES=[...'author.middlewares.AuthorDefaultBackendMiddleware',...]UsePricablebehavioral mixin to your model:fromprice_level.modelsimportPricableclassModel(Pricable,models.Model):...Now you can get current price for your category:price_level=model.get_current_price_level(category='company')FeaturesAdds PriceLevel models can be bound to your model classRunning TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.0 (2017-01-05)First release on PyPI.
Package: django-prices-openexchangerates
openexchangerates.org support fordjango-pricesfrompricesimportMoneyfromdjango_prices_openexchangeratesimportexchange_currencyconverted_price=exchange_currency(Money(10,currency='USD'),'EUR')print(converted_price)# Money('8.84040', currency='EUR')It will also create additional steps if it cannot convert directly:frompricesimportMoneyfromdjango_prices_openexchangeratesimportexchange_currencyconverted_price=exchange_currency(Money(10,currency='GBP'),'EUR')print(converted_price)# Money('13.31313588062401085236264978', currency='EUR')Theexchange_currencysupportsMoney,TaxedMoney,MoneyRangeandTaxedMoneyRange.Template filters can be used withdjango-pricesto convert currency, round amounts and display localized amounts in templates:{%loadprices_i18n%}{%loadprices_multicurrency%}<p>Price:{{foo.price.gross|in_currency:'USD'|amount}}({{foo.price.net|in_currency:'USD'|amount}}+{{foo.price.tax|in_currency:'USD'|amount}}tax)</p>InstallationFirst install the package:pip install django-prices-openexchangeratesThen add'django_prices_openexchangerates'to yourINSTALLED_APPS.Set following settings in your project's settings:OPENEXCHANGERATES_API_KEYOPENEXCHANGERATES_BASE_CURRENCY(defaults to'USD', only premium accounts support other bases)Use your admin console to createConversionRateobjects for each currency that you want to support.Updating exchange ratesFetch current rates from API with./manage.py update_exchange_ratesSchedule this task in cron job or in celery, to be always up to date with exchange ratesYou can use--allflag in above command, to create exchange rates automatically for all available currencies.
Package: django-principals
=================Django Principals=================This module provides ``PrincipalField``, a model field for Django_ that allowsinstances of a model to be defined as the principal instance for an entire model ora collection of instances. When the status of one instance is changed, the statusof other items in the collection are updated in response as necessary.Usage-----Add a ``PrincipalField`` to your model; that's it.If you want to work with all instances of the model as a single collection,there's nothing else required.  To create collections based on one or morefields on the model, specify the field names using the ``collection`` argument.In general, the value assigned to a ``PrincipalField`` will be handled like aunique Boolean value.  Setting the principal to ``True`` willcause all other items to become ``False``within the same collection --unless, of course, the collection has fewer than two elements.Multi-table model inheritance~~~~~~~~~~~~~~~~~~~~~~~~~~~~~By default, if a parent model has a principal field that declares a collection,child model instances are filtered independently. This behavior can be changedby specifying a `parent_link` argument identifying the name of the one-to-onefield linking the child model to the parent. If `parent_link` is set, all subclassinstances will be part of a single sequence in each collection.Limitations-----------* Unique constraints can't be applied to ``PrincipalField`` because they breakthe ability to update other items in a collection all at once.  This one wasa bit painful, because setting the constraint is probably the right thing todo from a database consistency perspective, but the overhead in additionalqueries was too much to bear.Credits-------This code loosely draws on concepts inspired by django-positions_ and django-featured-item_,two projects which provide custom model fields with different functionality... _`Django`: http://www.djangoproject.com/.. _`django-positions`: https://github.com/jpwatts/django-positions.. _`django-featured-item`:  https://bitbucket.org/tim_heap/django-featured-item
Package: django-print-models
django_print_modelsA Django package that provides a management command to print trimmed down
models for easier sharing. Prints your models withjustthe field
definitions, trimming out other methods, properties, etc.This is handy when you want to ask ChatGPT or fellow humans a question
where the context of your model field definitions is important (e.g. when
trying to build a complex query), but the rest of your crappy model
definition doesn't matter.Installationpip install django-print-modelsAdddjango_print_modelsto yourINSTALLED_APPSin Django settings.Usagepython manage.py print_models <app_name> <model_name1> <model_name2> ...ExampleGiven the following model definitions:importdatetimefromdjango.dbimportmodelsfromdjango.utilsimporttimezonefromdjango.contribimportadminclassQuestion(models.Model):question_text=models.CharField(max_length=200)pub_date=models.DateTimeField('date published')def__str__(self):returnself.question_text@admin.display(boolean=True,ordering='pub_date',description='Published recently?',)defwas_published_recently(self):now=timezone.now()returnnow-datetime.timedelta(days=1)<=self.pub_date<=nowclassChoice(models.Model):question=models.ForeignKey(Question,on_delete=models.CASCADE)choice_text=models.CharField(max_length=200)votes=models.IntegerField(default=0)def__str__(self):returnself.choice_textprint_modelswill print the following:> python manage.py print_models polls Question Choice
class Question(models.Model):
    id = models.BigAutoField(null=False, blank=True, db_index=False)
    question_text = models.CharField(max_length=200, null=False, blank=False, db_index=False)
    pub_date = models.DateTimeField(null=False, blank=False, db_index=False)

class Choice(models.Model):
    id = models.BigAutoField(null=False, blank=True, db_index=False)
    question = models.ForeignKey("Question", null=False, blank=False, db_index=True)
    choice_text = models.CharField(max_length=200, null=False, blank=False, db_index=False)
    votes = models.IntegerField(null=False, blank=False, db_index=False)Obviously in this simple example it would have been quite easy to just
copy/paste the relevant model definitions, but for larger, more complex
models this becomes tedious.
Package: django-print-settings
Adds aprint_settingsDjango management command.Setting it upInstall:pipinstalldjango-print-settingsAdddjango_print_settingstoINSTALLED_APPSin your Django project’ssettings.py:INSTALLED_APPS=('django_print_settings',...)UsageDo:pythonmanage.pyprint_settingsor:pythonmanage.pyprint_settings--format=jsonFor help:pythonmanage.pyprint_settings--helpPyPIhttps://pypi.python.org/pypi/django-print-settingsIssuesSend your bug reports and feature requests tohttps://github.com/msabramo/django-print-settings/issues
Package: django-print-sql
django-print-sql is an easy-to-use SQL debug tool for Django developers to print SQL statementsWhat’s new2018.3.6Added a decoratorIt now prints how long it takes each query to execute, as well as the total time elapsedRequirementsYou need to have django installed (obviously).I’ve tried it on Django 1.11.11 and 2.0.3.If sqlparse is installed, the SQL statement wil be formatted.InstallFrom pip, run:$ pip install --upgrade django-print-sqlConsider using the--useroption.From the repository, run:python setup.py installto install django-print-sql on your system.django-print-sql is compatible with Python 2.7 and Python 3 (>= 3.3) (hopefully :D).Install sqlparse to pretty print the statements:$ pip install --upgrade sqlparseUsageExample 1. Use as context manager:from django_print_sql import print_sql

# set `count_only` to `True` will print the number of executed SQL statements only
with print_sql(count_only=False):

  # write the code you want to analyze in here,
  # e.g. some complex foreign key lookup,
  # or analyzing a DRF serializer's performance

  for user in User.objects.all()[:10]:
      user.groups.first()Example 2. Use as decorator:from django_print_sql import print_sql_decorator


  @print_sql_decorator(count_only=False)  # this works on class-based views as well
  def get(request):
      # your view code hereLinksProject Pagehttps://github.com/rabbit-aaron/django-print-sqldjango-print-sql is licensed under the MIT license.Parts of the readme are based on sqlparse’s readme file.
sqlparse:https://github.com/andialbrecht/sqlparse