Saravanan666/pypi-org huggingface dataset:
Package: django-rated-reviews
Rated reviews application for DjangoRated reviews is derived fromDjango “excontrib” Commentsand can be used to attach reviews with rating to any model. The core difference from comments is that user can provide only one review per item. Rating is expressed by a number and by default visualized with stars. However, it can be changed to whatever you want. Rating grades are also configurable.Optionally rating can be weighted. For instance, you can designate experts whose rating would be more valuable. Alternatively, add weight to reviews of real byers of sold product.Documentation is publishedon Read the Docs.RequirementsPython 3.3+Django 1.11+Django CompatibilityDjango 1.11+Django 2.0+Django 3.0+InstallationInstalldjango-rated-reviewsusing pip:pipinstalldjango-rated-reviewsAddreviewstoINSTALLED_APPS. Example:INSTALLED_APPS=(...'reviews',...)Runmanage.py migrateso that Django will create the review tables.Add the reviews app’s URLs to your project’s urls.py:urlpatterns=[...url(r'^reviews/',include('reviews.urls')),...]Use the review template tags to embed reviews in your templates.CustomizationAll configuration settings are optional.REVIEW_MAX_LENGTHThe maximum length of the review comment field, in characters. Comments longer than this will be rejected. Defaults to3000.REVIEW_PUBLISH_UNMODERATEDIfFalse(default) reviews are not published until they are moderated in admin. If user modifies existing review it is considered unmoderated again.REVIEW_COMPOSE_TIMEOUTThe maximum review form timeout in seconds. The default value is2 * 60 * 60(2 hours).REVIEW_RATING_CHOICESCustom rating choices, each represented by one star (currently the maximum supported number is 10). Default choices are:REVIEW_RATING_CHOICES=(('1',_('Terrible')),('2',_('Poor')),('3',_('Average')),('4',_('Very Good')),('5',_('Excellent')),)REVIEW_SHOW_RATING_TEXTIfTrue(default) rating text (as specified by choices) is displayed next to rating stars.REVIEW_ALLOW_PROFANITIESIfFalsereview comment is checked against words inPROFANITIES_LIST. If it contains any of the words, review is rejected.REVIEW_ADMIN_LINK_SYMBOLReview admin exposes a link to review on a web site. By default it is shown as ▶. It can be changed to any other symbol or text,
e.g. if Font Awesome is attached to admin the following setting can be used:'<i class="fas fa-external-link-alt"></i>'.REVIEW_APPCustom reviews app can be set that will define customReviewForm,Reviewmodel or rating weight system.ExamplesCustom rating weight definitiondefget_review_user_weight(user,target):ifuser.has_perm('reviews.can_moderate'):return50from.modelsimportProduct,Orderifisinstance(target,Product):count=Order.objects.filter(user=user.pk,item__product=target.pk,status=Order.STATUS_DONE).count()ifcount>0:return10return1CreditsApplication code is derived fromDjango “excontrib” Comments.Rating widget usesstar-rating.js libraryby Paul Ryley.
Package: django-ratelimit
Django Ratelimit provides a decorator to rate-limit views. Limiting can
be based on IP address or a field in the request–either a GET or POST
variable.Code:https://github.com/jsocol/django-ratelimitLicense:Apache Software License 2.0; see LICENSE fileIssues:https://github.com/jsocol/django-ratelimit/issuesDocumentation:http://django-ratelimit.readthedocs.io/
Package: django-ratelimit2
Django Ratelimit provides a decorator to rate-limit views. Limiting can
be based on IP address or a field in the request–either a GET or POST
variable.Code:https://github.com/jsocol/django-ratelimitLicense:BSD; see LICENSE fileIssues:https://github.com/jsocol/django-ratelimit/issuesDocumentation:http://django-ratelimit.readthedocs.org/
Package: django-ratelimit3
This is the fork oforiginalDjango Ratelimit with some fixes
Django Ratelimit provides a decorator to rate-limit views. Limiting can
be based on IP address or a field in the request–either a GET or POST
variable.Code:https://github.com/lcd1232/django-ratelimit3License:Apache Software License 2.0; see LICENSE fileIssues:https://github.com/lcd1232/django-ratelimit3/issuesDocumentation:http://django-ratelimit.readthedocs.io/
Package: django-ratelimit9
django-ratelimit9combinesdjango-recaptchaanddjango-ratelimitinto a single app.Each time when a limit is exceeded a reCAPTCHA field is dynamically appended to a Form.Make sure you have read the docs of these two requirements in order to learn how to set up limits and customize the reCAPTCHA.Requirementsdjango-recaptchadjango-ratelimitInstallationInstall via pip:pip install django-ratelimit9Addratelimit9to yourINSTALLED_APPSUsageLet’s say you want to use viewMyViewalong withMyFormform.Code for yourforms.py:from django.forms import Form
from ratelimit9.forms import Ratelimit9Form

class MyForm(Ratelimit9Form, ModelForm):
        # ...Code for yourviews.py:from django.views.generic import CreateView
from ratelimit9.mixins import Ratelimit9Mixin

class MyView(Ratelimit9Mixin, CreateView):
        ratelimit_key = 'ip'
        ratelimit_rate = '5/m'
        # ...
Package: django-ratelimit-backend
Django-ratelimit-backendRate-limit your login attempts at the authentication backend level. Login
attempts are stored in the cache for 5 minutes and IPs with more than 30
failed login attempts in the last 5 minutes are blocked.The numbers (30 attempts, 5 minutes) as well as the blocking strategy can be
customized.Authors: Bruno Renié andcontributorsLicence: BSDCompatibility: Django 1.8 and greaterDocumentation:https://django-ratelimit-backend.readthedocs.ioCode:https://github.com/brutasse/django-ratelimit-backendCreditsSimon Willison for hisratelimitcacheideaHackinggit clone https://brutasse@github.com/brutasse/django-ratelimit-backend.gitHack and run the tests:python setup.py testTo run the tests for all supported Python and Django versions:pip install tox
tox
Package: django-rating
This package allows you to rate any of your objects with different type of ratings.Example:Let's say a user (as a participant) wants to rate the last session's content and the performer.rating_element_1=RatingElement.objects.create(element_type=RATING_ELEMENT_SESSION_CONTENT,score=5)rating_element_2=RatingElement.objects.create(element_type=RATING_ELEMENT_SESSION_PERFORMER,score=5)rating=ObjectRating.objects.create(user=my_user,user_type=USER_TYPE_PARTICIPANT,content_type=ContentType.objects.get(model="session"),object_id=Session.objects.last().id,)rating.elements.add(rating_element_1,rating_element_2)InstallationInstall the pip package:pipinstalldjango-ratingInstalldjango-rest-frameworkif not already installedaddratingandrest_frameworkto INSTALLED_APPSinclude 'rating.urls' into urlpatternsfromdjango.conf.urlsimporturl,includefromdjango.contribimportadminurlpatterns=[url(r'^admin/',admin.site.urls),url(r"",include("rating.urls")),]Migrate the db to crate rating modelspythonmanage.pymigrateDevelopClone the repogitclonegit@github.com:pulilab/django-rating.gitTest appTest standalone app:$ export DATABASE_URL='your_db'  # you can skip this, defaults to 'localhost' (use postgres.app for simplicity)$ pip install -r requirements.txt$ python runtests.pyRun the app in develop modeCreate a new django project and install the package in develop modedjango-adminstartprojectrating_democdrating_demo
pipinstall-e~LOCAL_PATH_TO_DJANGO_RATINGAddratingandrest_frameworktoINSTALLED_APPSinsettings.pyINSTALLED_APPS=['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','rest_framework','rating']Configure demo app urlsfromdjango.conf.urlsimporturl,includefromdjango.contribimportadminurlpatterns=[url(r'^admin/',admin.site.urls),url(r"^api/",include("rating.urls")),]SqlLite is not supportedChange the db config to use postgres insettings.py:DATABASES={'default':{'ENGINE':'django.db.backends.postgresql_psycopg2','NAME':'postgres','USER':'postgres','HOST':os.environ.get("DATABASE_URL",'localhost'),'PORT':5432,}}ConfigureConfigure the following values in settings:RATING_VALID_USER_TYPES: Defines the accepted user typesRATING_VALID_ELEMENT_TYPES: Defines the accepted rating element typesRATING_MIN_SCORE: Defines the minimum score for ratingRATING_MAX_SCORE: Defines the maximum score for ratingE.g.fromdjango.utils.translationimportugettext_lazyas_USER_TYPE_SESSION_HOST='H'USER_TYPE_SESSION_PARTICIPANT='P'ELEMENT_TYPE_SESSION_CONTENT='S'ELEMENT_TYPE_COMMENT='C'RATING_VALID_USER_TYPES=((USER_TYPE_SESSION_HOST,_('HOST')),(USER_TYPE_SESSION_PARTICIPANT,_('PARTICIPANT')))RATING_VALID_ELEMENT_TYPES=((ELEMENT_TYPE_SESSION_CONTENT,_('SESSION_CONTENT')),(ELEMENT_TYPE_COMMENT,_('COMMENT')))RATING_MIN_SCORE=1RATING_MAX_SCORE=5Migrate db, create super user and run your demo app:pythonmanage.pymigrate
pythonmanage.pycreatesuperuser
pythonmanage.pyrunserveropen the browser athttp://localhost:8000/admin
Package: django-ratings-models
Ratings for your Django modelsQuickstartInstall django-ratings-models:pip install django-ratings-modelsAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'ratings',...)Running TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackage
Package: django-rating-system
InstallationInstall using pippython-mpipinstalldjango-rating-systemor Clone the repository then copyratingfolder and paste in
project folder.gitclonehttps://github.com/mahyar-amiri/django-rating-system.gitConfigurationAddrating.apps.RatingConfigto installed_apps afterdjango.contrib.authin thesettings.pyfile. AddMEDIA_URLandMEDIA_ROOT.# setting.pyINSTALLED_APPS=['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',# MY APPS'rating.apps.RatingConfig',]...MEDIA_URL='/media/'MEDIA_ROOT=BASE_DIR/'media'Addpath('rating/',include('rating.urls')),and media root to
urlpatterns in the projecturls.pyfile.# urls.pyfromdjango.urlsimportpath,includefromdjango.confimportsettingsfromdjango.conf.urls.staticimportstaticurlpatterns=[path('rating/',include('rating.urls')),]urlpatterns+=static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)Connectratingsto target model. Inmodels.pyadd the fieldratingsas a GenericRelation field to the required model.NOTE:Please note that the field name must beratingsNOTrating.# models.pyfromdjango.dbimportmodelsfromdjango.contrib.contenttypes.fieldsimportGenericRelationfromrating.modelsimportRatingclassArticle(models.Model):title=models.CharField(max_length=20)content=models.TextField()# the field name should be ratingsratings=GenericRelation(Rating)Do migrationspythonmanage.pymigrateUsageIn the template (e.g. post_detail.html) add the following template
tags where obj is the instance of post model.{% load rating_tags %}Add the following template tag to load stylesheet.{% render_rating_import %}Add the following template tags where you want to render ratings.{% render_rating request obj settings_slug='default-config' %}  {# Render all the ratings belong to the passed object "obj" #}if your context_object_name is notobj(e.g. article) replace obj
with context_object_name.{% render_rating request obj=article settings_slug='default-config' %}Add the following template tag to show rating information.{% render_rating_info request=request obj=article settings_slug='default-config' %}usecustom_templateif you want to render your own template.{% render_rating_info request=request obj=article settings_slug='default-config' custom_template='my_custom_rating_info.html' %}Addrender_rating_scripttag at the end of the lastrender_ratingtag.{% render_rating_import %}

{% render_rating request=request obj=article settings_slug='default-config' %}
{% render_rating_info request=request obj=article settings_slug='default-config' %}

{% render_rating request=request obj=article settings_slug='like-config' %}
{% render_rating_info request=request obj=article settings_slug='like-config' custom_template='rating/rating_info.html' %}

{% render_rating_script %}
Package: django-raw-api
django-raw-apiAsync-friendly straightforward Django API helpersHello worldfromraw_apiimportvalidate_json@validate_json({"name":str})defhello(request):name=request.json["name"]ifname=="death":return"not today",403return{"hello":request.json["name"]}SetupInstall in from pypi:pip install django-raw-apiAddraw_apiintoINSTALLED_APPSlist of yoursettings.pyAddraw_api.middlewaremiddleware intoMIDDLEWAREAPIMiddlewareIt adds lazyrequest.jsonattribute and serializes raw responses such as:strortuple(message: str, status: int)- into plain text responsedictortuple(data: dict, status: int)- into JSON responseRequestrequest.json: dict- parsed jsonrequest.query: dict- parsed query (only after@validate_query)ResponseYou can just returnstrordictwith an optional status codedefjson_200ok(request):return{"hello":"world"}defplain_text_with_status(request):return"bad request",400AuthorizationDecorators@user_requiredand@staff_requiredis analogous to@login_requiredand@staff_member_requiredwith JSON-based errors instead
of redirectingBoth decorators cacherequest.userso you can use it withoutsync_to_asynceven in async views.fromraw_apiimportuser_required,staff_required@user_requiredasyncdefuser(request):# no `sync_to_async` requiredreturnrequest.user.username@staff_requireddefstaff(request):return{"admin":"zone"}Data validation@validate_queryand@validate_jsondecorators are there to perform simple
first-level validation of requests data. Internally they use thetrafaretlibrary.fromraw_apiimportvalidate_json,validate_query@validate_json({"ids":[int],"hello?":str})asyncdeffoo(request):returnrequest.json@validate_query({"id":int})defbar(request):assertisinstance(id,int)returnrequest.queryExamplesThere's an example of using it withasync viewsin theexamplesfolder.Testspython-mvenv.venvsource.venv/bin/activatepipinstall-Urrequirements-dev.txtpython-mpytesttests
Package: django-raw-clearsessions
By default, Django’scached_dbanddbsession backends loop
through deleted sessions in order to trigger pre/post delete signal
handlers. This can beextremelyslow and consumea lotof CPU and
memory on sites with a lot of sessions.This package provides aSessionStoreMixinclass and alternativecached_dbanddbbackends that use the private_raw_delete()method, which is much faster and consumes much less CPU and memory, but
does not trigger pre/post delete signal handlers.UsageAdd to your settings:SESSION_ENGINE = 'django_raw_clearsessions.cached_db'Or:SESSION_ENGINE = 'django_raw_clearsessions.db'Or:# mybackend.py
from some.package import some_backend
from django_raw_clearsessions import SessionStoreMixin


class SessionStore(SessionStoreMixin, some_backend.SessionStore):
    pass

# settings.py
SESSION_ENGINE = 'mybackend'Execute the Djangoclearsessionsmanagement command:$ python manage.py clearsessions
Package: django-rayo-express
django-rayoStartingThese instructions will allow you to install the library in your python project.Current featuresGet default payload.Create shipping.Pre-requisitosPython >= 3.7Django >= 3requests >= 2InstallationTo get the latest stable release from PyPi:pip install django-rayoorFrom a buildgit clone https://gitlab.com/linets/ecommerce/oms/integrations/django-rayocd {{project}}python setup.py sdistand, install in your project djangopip install {{path}}/django-rayo/dist/{{tar.gz file}}Settings in django projectDJANGO_RAYO = {
    'RAYO': {
        'BASE_URL': '<RAYO_BASE_URL>',
        'USER': '<RAYO_USER>',
        'KEY': '<RAYO_KEY>',
    }
}UsageCreate instance to be sentimport json
from types import SimpleNamespace

dict_ = {
    'reference': '99999',
    'created_at': '12/12/21',
    'shipping_date': '12/12/21',
    'expiration_date': '26/12/21'
    'tracking_code': '6075620-1',
    'transport_guide_number': '1121632479536-01-1',
    'purchase_number': 'CLV0048146676851-1',
    'customer': {
        'first_name': 'Marcos',
        'last_name': 'Sac',
        'full_name': 'Marcos Sac',
        'phone': '932932932',
        'email': 'test@gmail.com',
        'rut': '16936195-9'
    },
    'address': {
        'street': 'ALEJANDRO VENEGAS CADIZ',
        'number': '513',
        'unit': 'DEPTO 6A',
        'full_address': 'ALEJANDRO VENEGAS CADIZ 513 DEPTO 6A'
    },
    'commune': {
        'name': 'Aisen',
        'code': '',
        'zone_code': '11201',
        'zone_post': 'WPA',
    },
    'location': {
        'code': 'MONTANDON',
        'name': 'MNN',
    },
    'region': {
        'name': 'Aysén del General Carlos Ibáñez del Campo',
        'code': '11',
        'iso_code': 'CL-XI',
    }
}

instance = json.loads(json.dumps(dict_), object_hook=lambda attr: SimpleNamespace(**attr))Get default payload:from rayo.handler import RayoHandler

handler = RayoHandler()
default_data = handler.get_default_payload(<instance>)Create shipping:from rayo.handler import RayoHandler

handler = RayoHandler()
default_data = handler.create_shipping(<default_data>)Get events:from rayo.handler import RayoHandler

handler = RayoHandler()

raw_data = {
    'tracking_number': 999999,
    'status': 'Exitoso',
    'events': [{
        'city': 'Santiago'
        'state': 'RM',
        'description': 'Llego al almacén',
        'date': '12/12/2021'
    }]
}
response = handler.get_events(raw_data)

Output:
[{
    'city': 'Santiago'
    'state': 'RM',
    'description': 'Llego al almacén',
    'date': '12/12/2021'
}]Get status and if "is_delivered":from rayo.handler import RayoHandler

handler = RayoHandler()

raw_data = {
    'tracking_number': 999999,
    'status': 'Exitoso',
    'events': [{
        'city': 'Santiago'
        'state': 'RM',
        'description': 'Llego al almacén',
        'date': '12/12/2021'
    }]
}
response = handler.get_status(raw_data)

Output:
('Exitoso', True)
Package: django-razorpay
django-razorpayRazorpay payment gateway integration in a django projectInstallationInstall using pip:pipinstalldjango-razorpayAdd toINSTALLED_APPSin yoursettings.py:INSTALLED_APPS=(# ..."django_razorpay",# ...)DJ_RAZORPAY={"organization_name":"Acme Corp","organization_email":"something@gmail.com",# Optional"organization_domain":"https://something.com","organization_logo":"https://company.com/orlogo.png",# Optional,"nav_links":[("Membership Fee","/payments/membership-fee"),("Transactions","/payments/transactions"),("Adhoc Pay","/payments/adhoc"),("Manual transaction","/payments/manual-transaction")],"RAZORPAY_VARIANTS":{"public_key":"rzp_test_6GvpLSAmWckaMk","secret_key":"Vo9OgyOw1FqGufiqhlWu4Fy32kl","currency":"inr"},"RAZORPAY_ENABLE_CONVENIENCE_FEE":True,# You charge a convenience fee to your customer."USE_PAYMENT_LINK":True# If enabled it will create payment link, will not use checkout page}fromdjango.contrib.messagesimportconstantsasmessagesMESSAGE_TAGS={messages.DEBUG:'alert-info',messages.INFO:'alert-info',messages.SUCCESS:'alert-success',messages.WARNING:'alert-warning',messages.ERROR:'alert-danger',}Include the django_razorpay URLconf in your project urls.py like this tourls.py:fromdjango.urlsimportpath,includeurlpatterns=[path('payments/',include('django_razorpay.urls',namespace="django_razorpay")),# ....]Runpython manage.py migrateto create the django_razorpay models.Runpython manage.py dj_razorpay_initto initialize models models.If you want to add members, create superuser, login and add.Visithttp://127.0.0.1:8000/payments/for payments.DemoA demo app is provided in example.
You can run it from your virtualenv with python manage.py runserver.
Package: django-rbac-permissions
Django RBAC PermissionsA Django package which enables RBAC with hierarchy and constraints enabled.Quick StartAdddjango_rbac_permissionsto your INSTALLED_APPS setting like this:INSTALLED_APPS=[...'django_rbac_permissions','django_json_widget'# Optional]If you want to see your JSONFields in a pretty widget, includedjango_json_widgetin your INSTALLED_APPS as well.Runpython manage.py migrateto create the models.If you want to define your modules (applications) in which you have
resources which should check for role authorization, you must define
a module configuration model. Ex:classRoleModuleConfiguration(models.Model):posts=models.BooleanField(default=True)users=models.BooleanField(default=True)role_name=models.CharField(max_length=255)Each BooleanField symbolizes a module (application) and decides whether
the given role_name is authorized to access it.You must also setMODULE_CONFIGURATION_PATHas the path, in which your model is residing.If you also want to control the authorization in your admin page, you must
add the middleware classCheckAdminRoleAuthorizationMiddlewareto your
MIDDLEWARE configuration in your Django settings file:MIDDLEWARE=[...'rbac_permissions.middleware.CheckAdminRoleAuthorizationMiddleware']There are some optional configuration parameters that you can set in your settings.py file.GRANT_NONEXISTENT_PATH_ACCESSdecides whether you want to grant access to a nonexistent resource (in this case, this means either the url does not exist or the url is not added to any Transaction yet.) The default isFalse.PERMISSION_DENIED_URLsets the url name of your view, which returns a HTTP_FORBIDDEN_403 status code. This will be the view, which will be redirected by the decoratoruser_groups_required, if the user is denied access. The default ispermission-denied.HTTP_FORBIDDEN_MESSAGEis the default message when the user is denied access. Completely optional.ROLE_RULE_DENIED_ACCESS_MESSAGEis the message returned by the view, when the required role matches one of the user's roles, but the current rule set of the Transaction denies access to this user's role or roles. Completely optional.Start the development server and visithttp://127.0.0.1:8000/admin/to create a Role or Transaction.NotesIf you internally route your views to other views in your application, there seems
to be a bug related to Django's authentication backends, which results in removing the current user from the request context.
So if you are using this pattern often in your code, make sure you pass 'rbac_user={current_user_id}' as a query parameter, so that the current authenticated user is fetched from the database instead from the request object.This is a temporary solution, will be trying to find a more suitable solution.
Package: django-rclone-storage
Django Rclone StorageA simple wrapper for Rclone as a Django storage.UsageFirst, add these settings to your Django settings:# The remote name in your rclone.confRCLONE_REMOTE='onedrive'# Remote path where all the files will be uploaded. Default: /RCLONE_REMOTE_ROOT='/'# Local path where your rclone.conf locates. If it's not set, rclone should use the default .conf file.RCLONE_CONFIG_PATH='/path/to/config'And, set the default storage:DEFAULT_FILE_STORAGE='rclonestorage.rclone_remote.RcloneRemoteStorage'Or, you can just pass the settings to a RcloneRemoteStorage object and use it in the FileField:file=models.FileField(storage=RcloneRemoteStorage(remote='remote',root_path='/',config_path='/path/to/config'))Referencedjango-storagespython-rclone
Package: django-rds-db-multitenant
1. Install$ pip install django-rds-db-multitenant2. Implement a mapper3. Update settings.pySet the multitenant mapper by specifying the full dotted path to your
implementation (in this example,mapperis the name of filemapper.py):MULTITENANT_MAPPER_CLASS='myapp.mapper.TenantMapper'Install the multitenant middleware as thefirstmiddleware of the list (prior to Django
1.10, you must use theMIDDLEWARE_CLASSESsetting):MIDDLEWARE=['rds_db_multitenant.middleware.MultiTenantMiddleware',....]Change your database backend to the multitenant wrapper:DATABASES={'default':{'ENGINE':'rds_db_multitenant.db.backends.mysql','NAME':'devnull',}}Note: theNAMEis useless for MySQL but due to a current
limitation, the named database must exist. It may be empty and
read-only.Optionally, add the multitenant helperKEY_FUNCTIONto your cache
definition, which will cause cache keys to be prefixed with the value ofmapper.get_cache_prefix:CACHES={'default':{'LOCATION':'127.0.0.1:11211','BACKEND':'django.core.cache.backends.memcached.MemcachedCache','KEY_FUNCTION':'rds_db_multitenant.cache.helper.multitenant_key_func'}}