Saravanan666/pypi-org huggingface dataset:
Package: django-randomfilenamestorage
A Django storage backend that gives random names to files.By default,django.core.files.storage.FileSystemStoragedeals with
conflicting filenames by appending an underscore to the file. For
instance, if you try to createhello.txtwhen it already exists,
it will rename it ashello_.txt.django-randomfilenamestoragecreates random filenames, so if you
try to createhello.txt, it will save it as7z0a8m25sh9fyitx.txt. Directory names and extensions are
preserved, only the root filename is randomized.InstallingThe easiest way to installdjango-randomfilenamestorageis to usepip:pip install django-randomfilenamestorageQuick StartIn your Djangosettingsfile:SetDEFAULT_FILE_STORAGEto'django_randomfilenamestorage.storage.RandomFilenameFileSystemStorage'Optionally, add'django-dbstorage'toINSTALLED_APPSThis gives you random filenames, backed on Django’sFileSystemStoragestorage class.RandomFilenameMetaStorageYou can define a new underlying storage class by usingRandomFilenameMetaStorageto wrap it:from django.core.files.storage import get_storage_class

from django_randomfilenamestorage.storage import RandomFilenameMetaStorage

RandomFilenameMyStorage = RandomFilenameMetaStorage(
    storage_class=get_storage_class('myapp.storage.MyStorage'),
)RandomFilenameMetaStorage defaults to 16-character root filenames.  To
change the default, definesettings.RANDOM_FILENAME_LENGTHto a different integer
value.To change the filename length of a wrapped storage class, pass in alengthargument toRandomFilenameMetaStorage. To override it
for a particular storage instance, pass in arandomfilename_lengthargument to its constructor.Efficient random filename generationRandomFilenameMetaStorage is careful about not overwriting existing
files, on creation. Unfortunately, many storage classes do not throw
anOSErrorwithEEXISTSwhen they detect a duplicate file on_save().If the underlying storage class acceptsuniquify_names=Falsein
its constructor,RandomFilenameMetaStoragewill reduce the number
of round-trips to the underlying storage class and make random
filename generation more efficient.Safe storage classes include:django_randomfilenamestorage.storage.SafeFileSystemStoragedjango-dbstorage.
Package: django-random-id
Django Random IDA model base class which provides custom designed random integer primary keys
to you Django models.InstallationRun the following to install:pipinstalldjango_random_idUsageThe original way of creating and assigning primary keys in Django modelsfromdjango.dbimportmodelsclassCustomUser(models.Model):name=models.CharField(max_length=30,blank=False)steve=CustomUser.objects.create(name="Steve")bill=CustomUser.objects.create(name="Bill")print(steve.id)# >>> '1'print(bill.id)# >>> '2'The primary keys are auto-incremental integers.Now, let's see howRandomIDModelhelps you:fromdjango.dbimportmodelsfromdjango_random_idimportRandomIDModelclassCustomUser(RandomIDModel):name=models.CharField(max_length=30,blank=False)steve=CustomUser.objects.create(name="Steve")bill=CustomUser.objects.create(name="Bill")print(steve.id)# >>> '425291518806427'print(bill.id)# >>> '607559381880556'The Random primary ID is guaranteed to be unique.By default the ID will be 16 digits long, but you can change this in
settings.py with theRANDOM_ID_MODEL_LENGTHsetting.You can also useRandomAlphaNumIDModelbase model to generate string
alphanumerical primary keys.Testing - In ProgressTo install django_random_id, along with the tools you need to develop and
run the tests, run the following in your virtual environment:$pipinstall-e.[dev]
Package: django-random-id-generator
django-random-id-generatorWhat is it?django-random-id-generator is a simple Django app to Generate Random and Unique IDs for Django model objects with custom save methodInstallationYou can getdjango-random-id-generatorby :Download or git clonehttps://github.com/frankovo/django-random-id-generator.gitUsageAddrandom_idto your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    # Django default apps
    ...
    'random_id',
]Runpython manage.py makemigrations random_idRunpython manage.py migrateRunpython manage.py createsuperuserRunpython manage.py runserverGo tohttp://127.0.0.1:8000/admin/RequirementsDjango==2.0.3NoteDjango==2.0.3 requires Python 3.4, 3.5, 3.6
Package: django-random-id-model
Django Random ID ModelThis module provides a base class for Django models that gives them a random
primary key id.For example, this is the vanilla way to do primary keys:fromdjango.dbimportmodelsclassCustomer(models.Model):name=models.CharField(max_length=50)customer1=Customer.objects.create(name="John")customer2=Customer.objects.create(name="Jane")print(customer1.id)# '1'print(customer2.id)# '2'The primary key just auto increments.Now useRandomIDModel:fromdjango.dbimportmodelsfromdjango_random_id_modelimportRandomIDModelclassCustomer(RandomIDModel):name=models.CharField(max_length=50)customer1=Customer.objects.create(name="John")customer2=Customer.objects.create(name="Jane")print(customer1.id)# '725393588906066'print(customer2.id)# '905529381860540'The ID is guaranteed to be unique.By default the ID will be 12 digits long, but you can override this in
settings.py with theID_DIGITS_LENGTHsetting.RandomIDModelinherits directly frommodels.Modeland does not interfere
with anything else, so you can use it wherever you would usemodels.Model.Forms and AdminTo integrate your model with a Django ModelForm, you will need to manually
exclude theidfield:fromdjango.formsimportModelFormclassCustomerForm(ModelForm):classMeta:model=Customerexclude=["id"]Likewise if you use the Django Admin app:fromdjango.contribimportadminclassCustomerAdmin(admin.ModelAdmin):exclude=["id"]admin.site.register(Customer,CustomerAdmin)
Package: django-random-image
django-random-image is a simple django app for using an image randomly from a user-defined set ofdjango-filerimages in a django template. Every image is only active during a time range set for it.Requiresdjango-filer.Quick startInstall with your favorite toolAdd'random_image'toINSTALLED_APPS.Migrate your database.You can now add images in the admin underRandom images.Add{% load random_image %}to your template of choice and use{% random_image as image %}to load a randomly selected image into theimagetemplate variable.
Package: django-random-image-from-folder
Django Random Image From FolderDjango Random Image From Folder is a simple app to load a random image from a specified directory.It's trivially simple but I've needed it a few times so I thought maybe others have too.InstallationAdd 'random_image' to INSTALLED_APPS.SettingsAll settings are optionalRANDOM_IMAGE_DIRDefault: Not definedA path to the directory from which to load the random images. Relative to MEDIA_ROOT.Note: Passing a path to the template tag will always override the RANDOM_IMAGE_DIR setting.RANDOM_IMAGE_EXTENSIONSDefault: ['.jpg','.jpeg','.png','.gif']A list containing extensions to be considered when choosing a random image.UsagePass in a path to the image directory::{% load random_image %}
<img src="{{ MEDIA_URL}}{% random_image "path/to/image/dir" %}">The path to the image directory should be relative to MEDIA_ROOT.or if you have added RANDOM_IMAGE_DIR to your settings file::{% load random_image  %}That's it! Simple as it gets.
Package: django-randompinfield
Generates a random pin for your Django model field.InstallationInstall via pip:$pipinstalldjango-randompinfieldAdd to your installed apps:INSTALLED_APPS=(...'randompinfield',...)UsageImportRandomPinFieldinto yourmodels.py.fromdjango.dbimportmodelsfromrandompinfieldimportRandomPinFieldclassMyModel(models.Model):slug=RandomPinField(length=3)Thelengthis an optional argument.
Package: django-random-queryset
Pull random records using Django ORM.RequirementsPython 3.8+Django 3.2+Installation$pipinstalldjango-random-querysetSetupAddRandomManagerto desired model:fromdjango.dbimportmodelsfromdjango_random_querysetimportRandomManagerclassModel(models.Model):objects=RandomManager()# ...No database migrations are needed.How to use it:queryset=Model.objects.filter(field=value)queryset.random()# to get one random recordqueryset.random(5)# to pass limited random recordsqueryset.random(len(queryset))# to get all random recordsqueryset.random().values()# to have access to other queryset methods
Package: django-randomslugfield
Django field that automatically generates random slugs.e.g. example.com/kEwD58PTested with Python 2.7, 3.3+ and Django 1.4+.Getting itTo install django-randomslugfield:$pipinstalldjango-randomslugfieldInstallTo enablerandomslugfieldin your project you need to add it toINSTALLED_APPSin your projectssettings.pyfile:INSTALLED_APPS=(...'randomslugfield',...)UsageImportRandomSlugFieldand use it in your model:fromdjango.dbimportmodelsfromrandomslugfieldimportRandomSlugFieldclassMyModel(models.Model):slug=RandomSlugField(length=7)Thelengthargument is required.Advanced UsageBy default randomslugfield generates its slug using these characters:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789You can optionally exclude lowercase/uppercase/digits/vowels usingexclude_lower=True,exclude_upper=True,exclude_digits=True,exclude_vowels=True.You cannot exclude all characters.Example:classMyModel(models.Model):slug=RandomSlugField(length=7,exclude_lower=True)The total number of unique slugs is determined bycharacters^length.62^9 = 13,537,086,546,263,552 possible slugs
62^8 = 218,340,105,584,896 possible slugs
62^7 = 3,521,614,606,208 possible slugs
62^6 = 56,800,235,584 possible slugs
62^5 = 916,132,832 possible slugs
Package: django-rangefilter
django-admin-rangefilterA Django app that adds a filter by date range to the admin UI.RequirementsPython 2.7+ or Python 3.6+Django 1.8+InstallationUse your favorite Python package manager to install the app from PyPI, e.g.Example:pip installdjango-rangefilterAddrangefiltertoINSTALLED_APPS:Example:INSTALLED_APPS=(...'rangefilter',...)Example usageIn adminfromdjango.contribimportadminfromrangefilter.filtersimportDateRangeFilter,DateTimeRangeFilterfrom.modelsimportPost@admin.register(Post)classPostAdmin(admin.ModelAdmin):list_filter=(('created_at',DateRangeFilter),('updated_at',DateTimeRangeFilter),)# If you would like to add a default range filter# method pattern "get_rangefilter_{field_name}_default"defget_rangefilter_created_at_default(self,request):return(datetime.date.today,datetime.date.today)# If you would like to change a title range filter# method pattern "get_rangefilter_{field_name}_title"defget_rangefilter_created_at_title(self,request,field_path):return'custom title'Support Content-Security-PolicyFor Django 1.8+, ifdjango-cspis installed, nonces will be added to style and script tags.
The settingADMIN_RANGEFILTER_NONCE_ENABLEDcontrols this behavior.INSTALLED_APPS=(...'rangefilter','csp',...)
Package: django-rangepaginator
This Django app provides a templatetag to render pagination widgets which include a range of pages around the current active one.StatusInstallationpipinstalldjango_rangepaginatorUpdate your Django settings:INSTALLED_APPS+=['django_rangepaginator']# Use bootstrap4 templateRANGE_PAGINATOR_TEMPLATE='django_rangepaginator/bootstrap3.html'# Use bootstrap3 template (default)RANGE_PAGINATOR_TEMPLATE='django_rangepaginator/bootstrap4.html'Usage{%loadrangepaginator%}{%paginatepagerequest=request%}The following options are available:distance: number of pages around current active one (default = 2)edge: number of pages at the start and end (default = 1)extra_class: add extra css classes to the pagination div (default = ‘’)text_labels: use strings for previous/next instead of symbols (default = True)DemoA sandbox environment is available in the repository, run the following:./sandbox/manage.pymigrate./sandbox/manage.pyrunserverBugs/featuresLet me know! :-)
Package: django-rank-query
Enable SQL Window functions for use in Django queries. Add rank to your query.Django in curren’t version (1.10) doesn’t support [window functions](https://www.postgresql.org/docs/9.3/static/functions-window.html) as seen in PostgreSQL.
This implemetsrank,dense_rankand adds shortcut forupper_rank, which retrieves upper value for rank (rank of last element in the window).
The implementation is currently working only on PostgreSQL.Note: The support for window functions is being already solved in [issue #26608](https://code.djangoproject.com/ticket/26608).QuickstartInstall rank:pip install django-rank-queryUsageU can annotate users by rank (sequenc number in alphabet) of their
last name the like this:from rank import DenseRank, UpperRank, Rank
users = User.objects.all()
users = user.annotate(lower_rank=Rank('last_name'))
users = user.annotate(upper_rank=UpperRank('last_name'))
users = user.annotate(dense_rank=DenseRank('last_name'))Then you have user query annotated with various ranks. You can retrieve them for example byvaluesfunction:user_ranks = users.values('last_name', 'lower_rank', 'upper_rank')Note: PostgreSQL doesn’t support combiningrankfunctions withGROUP_BYor inWHEREclause. So you cannot use them in aggregation queries.Rank is counted in the currentselectquery, so filtering will change rank of given elements, so you can’t have sequence number in whole table filtered by ie. his name.
This can be solved by using subqueries in SQL, but Django doesn’t support them as far as I know.Running 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-20)First release on PyPI.
Package: django-ranks
Not ready yet, DO NOT USEDjango Ranks is a Django app to conduct web-based Django Ranks. For each question,
visitors can choose between a fixed number of answers.Detailed documentation is in the “docs” directory.Quick startAdd “Django Ranks” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...,
    "django_ranks",
]Include the Django Ranks URLconf in your project urls.py like this:path("ranks/", include("django_ranks.urls")),Runpython manage.py migrateto create the Django Ranks models.Start the development server and visithttp://127.0.0.1:8000/admin/to create a poll (you’ll need the Admin app enabled).
Package: django-rapidapi
Django RapidAPI (in progress)Django Rapid API extension.Inspired byFastAPIandDjango Rest Framework.Documentation:https://django-rapidapi.readthedocs.io/InstallingInstall usingpip:pipinstalldjango-rapidapiTODO:DocumentationOpenAPI support (Swagger, ReDoc)Pydantic supportAsync views support (with Django 3.1)etc.
Package: django-rapyd-modernauth
# Django Rapyd ModernAuthThis package provides a customUsermodel where the username is the email address.## InspirationUsers today expect to use their email address as the username during authentication. This works well because:Users already know their email addresses by heart.Since email addresses are unique, users don’t need to remember yet another item when either signing up or logging into web applications. IMHO this is a significant factor that plays a vital role in user adoption.This is a time tested model and many web applications today follow this.However, Django’s default approach for authentication requires a user provide both a username and an email address during sign up and then just use the username during login.## UsageNote:Django recommends you do this right at the beginning of the project. Making this change mid-project becomes significantly harder.Install the package with:` pip installdjango-rapyd-modernauth`Edit Django settings:
- AddmodernauthtoINSTALLED_APPS.
- SetAUTH_USER_MODEL = modernauth.User.Create models with:` ./manage.py migrate `
Package: django-rapyd-wiretap
Logs requests and responses to your application in a DB for auditing or troubleshooting purposes.InspirationThis is heavily inspired by and borrows a lot fromnathforge/django-wiretap.Why a new package?The fundamental difference is not lettingsettings.DEBUGdetermine if a message should be tapped. I have needs, yes inPRODUCTION, where this is useful to me.UsageInstall the package with:pip install django-rapyd-wiretapEdit Django settings:AddwiretaptoINSTALLED_APPS.Addwiretap.middleware.WiretapMiddlewareto yourMIDDLEWARE_CLASSES.Create models with:./manage.py migrateGo to Django admin, add a newTap.This contains apath, which is matched against the full path including the query string. A valid regex is allowed here.For example, to capture everything within the/api/path of your site, use^/api/.To capture everything, set it to/.To DoAdd support for configuring retention per tap and deleting older messages.Add support for prettifying major content types for easy troubleshooting.Delegate logging request and response bodies to a separate file on the file system keeping the DB lean for faster queries. Maybe? I’m still divided on this.I’m sure there are other things I haven’t thought of yet or those that will be needed by the community.
Package: django-ratchet
django-ratchet is a simple middleware for reporting errors from Django apps toRatchet.io.Requirementsdjango-ratchet requires:Python 2.6 or 2.7Django 1.4+requests 0.13.1+aRatchet.ioaccountInstallationInstall using pip:pip install django-ratchetConfigurationBasic configuration requires two changes in yoursettings.py.Add'django_ratchet.middleware.RatchetNotifierMiddleware'as the last item inMIDDLEWARE_CLASSES:MIDDLEWARE_CLASSES = (
    # ... other middleware classes ...
    'django_ratchet.middleware.RatchetNotifierMiddleware',
)Add theRATCHETsettings dictionary somewhere insettings.py. The bare minimum is:RATCHET = {
    'access_token': '32charactertokengoeshere',
}Most users will want a few extra settings to take advantage of more features:RATCHET = {
    'access_token': '32charactertokengoeshere',
    'environment': 'production',
    'branch': 'master',
    'root': '/absolute/path/to/code/root',
}To make theRATCHETsettings available in your templates asratchet_settings, add the context processor:from django.conf import global_settings
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
  'django_ratchet.context_processors.ratchet_settings',
)Here’s the full list of configuration variables:access_tokenAccess token from your Ratchet.io projectenvironmentEnvironment name. Any string up to 255 chars is OK. For best results, use “production” for your production environment.default:developmentifsettings.DEBUGisTrue,productionotherwisehandlerOne of:blocking – runs in main threadthread – spawns a new threadagent – writes messages to a log file for consumption byratchet-agentdefault:threadtimeoutRequest timeout (in seconds) when posting to Ratchet.default:1rootAbsolute path to the root of your application, not including the final/. If yourmanage.pyis in/home/brian/www/coolapp/manage.py, then this should be set to/home/brian/www/coolapp. Required for Github integration.branchName of the checked-out branch. Required for Github integration.agent.log_fileIfhandlerisagent, the path to the log file. Filename must end in.ratchetendpointURL items are posted to.default:https://submit.ratchet.io/api/1/item/web_baseBase URL of the Ratchet.io web interface. Used for “view in ratchet.io” links.default:https://ratchet.iopatch_debugviewIf True, django.views.debug will be patched to show a “View in Ratchet.io” link on technical 500 debug error pages.default:TrueContributingContributions are welcome. The project is hosted on github athttp://github.com/ratchetio/django-ratchetAdditional HelpIf you have any questions, feedback, etc., drop us a line atsupport@ratchet.io
Package: django-ratchet-scss
ratchet-scss is a simple Django app to conduct Web-based ratchet-scss.to, see what is ratchet, just visithttp://goratchet.comQuick startrefere django libscss config firsthttps://github.com/torchbox/django-libscssAdd “ratchet-scss” to your INSTALLED_APPS setting like this:INSTALLED_APPS = (
    ...
    'ratchet_scss',
)import the scss directly in your scss file@import “ratchet”;enjoy it. bootsrap is in your scss project
Package: django-rated
django-ratedA rate limiting decorators for DjangoIntroduction`rated`` allows you to limit request rates a single client may attempt on views in 'realms' of your site.You control which views are in which 'realm' by either decorating the view, or adding the url pattern into the realm map.ratedwill keep track of how many requests, and when, a client has made and, if they've exceeded their limit, will return a configurable response --503 - Service Unavailableby default.InstallingDecorate your views:@rate_limit('myrealm')defmyview(request):ConfiguringNext, configure your realms.This is done by defining them in the RATED_REALMS setting.  This is a dict where the keys are realm names, and the values are dicts of configs.A realm config may contain any of the following keys.  Any omitted fall back to the defaults from the settings below.allowed:  A list of IPs to exclude from rate limiting.
duration:   Time after which any requests are forgotten
limit:      Number of requests before limiting is applied.
code:       HTTP Status code to use when limiting is applied.
message:    Response content to return when limiting is applied.If you're planning to put all limited views into the one realm, you don't need to define RATED_REALMS - the defaults will be used instead.Assign RealmsThere are three ways to apply rate limits.  Either decorate the view directly, add a realm with the same url pattern name, or map the url pattern name to a realm.You can add mark a view as in the default realm simply:fromrated.decoratorsimportrate_limit@rate_limitdefmyview(...)To add it to a specific realm:@rated_realm(realm='other')defmyview(...)Otherwise, if the url pattern is named, and the name matches a realm name, it will be considered part of that realm.  There is also the RATED_REALM_MAP, which will map url pattern names to realm names.  The url pattern name is always mapped through here.SettingsRATED_DEFAULT_TIMEOUT:How long an access history persists with no accesses.
Default: 1 hourRATED_DEFAULT_LIMIT:Limit of how many requests an individual client is permitted per hour.
Default: 100RATED_RESPONSE_CODE:HTTP Status code to return when a request is limited.
Default: 429RATED_RESPONSE_MESSAGE:Content to include in response when a request is limited.
Default: ''RATED_REALMS:A dict of config dicts.
The keys are realm names.
The values are dicts containing overrides for 'limit', 'timeout' and 'allowed'.
Default: {}RATED_REDIS:Redis config settings.
These will be passed directly to create a redis.ConnectionPool instance.RATED_DEFAULT_ALLOWED:A list of IPs which are exempt from rate limiting.