Saravanan666/pypi-org huggingface dataset:
Package: django-urlman
django-urlmanURL manager for DjangoDjango is powerful, we want it to be as simple as possible without sacrificing flexibility.UsageAssume the django project is named 'mysite', in the project's url-config file (mysite/urls.py):fromdjango_urlmanimportmounturlpatterns=[# original django urlspath('polls/',include('polls.urls')),path('admin/',admin.site.urls),# django-urlman aware apps*mount('mysite',# main project name{'app1':'app1/',# mount app1 at anchor 'app1/''app2':'app2/',# mount app2 at anchor 'app2/'}),]In app1 module:fromdjango_urlmanimporturl@urldefhi(_):returnHttpResponse('Hello World')Then the api endpoint "app1/hi" should return "Hello World".
Package: django-urlmapper
Urlmapper is a library for Django to print out the registered urls for a
site in a readable format.Basic Usagefrommysite.urlsimporturlpatternsfromurlmapper.utilsimportget_urlsurls=get_urls(urlpatterns)forentryinurls:print(entry["path"],entry["name"],entry["view"])A urlpattern like:extra=[url("^world/$",view),]nested=[url(r"^(?P<slug>\w+)/",include([url(r"^$",view),url(r"^history/$",view),url(r"^edit/$",view),])),]urlpatterns=[url("^$",view),url("^product/(?P<slug>[^/]+)/$",view,name="product-detail"),url("^about/$",view,name="about"),url("^hello/",include(extra)),url("^page/",include(nested)),]Would output like:/
/about/
/hello/world/
/page/<slug>/
/page/<slug>/edit/
/page/<slug>/history/
/product/<slug>/InstallationUrlmapper can be installed from PyPI:pip install django-urlmapperCreditsThis code was originally modified from the django-extensions library for
use in things other than Django management commands.
Package: django-url-methods
Django-url-methods provide various methods to work with urls.This application is used by django-trusted-html and django-model-url.Installation:Just puturlmethodsin to yourINSTALLED_APPSin yoursettings.pywithin your django project.Requirements:Django 1.3+ is required.
For django < 1.3 please check out django-url-methods 0.1.0.
Package: django-url-migration
A custom 404 handler that uses fixed or regex rules to redirect from old to new urls.Fixed URL -> URL rulesRegex rulesUsage loggingRemoval of unused url migrationsConfigurationAdd custom 404 handler to your mainurls.py:` handler404 = 'url_migration.views.page_not_found' `Addurl_migrationto yourINSTALLED_APPS.Run migrations (manage.py migrate)Check your Django admin for the url_migration models:Url mappings: fixed url -> url rulesUrl regexp mappings: regex rules that will generate url mapping for every regex match.Theremove_expired_redirectsmanagement command may be used to remove expired url mappings - if the mapping isn’t used for given expiry time it will be removed (so you can see which old urls are still used).Every mapping hit is being logged toLastUsageLogmodel.You can also check url_migration_demo project in this repository.
Package: django-url-namespaces
django-url-namespaces=====================This is a somewhat-functional attempt to bring a more intuitive and less spaghettified syntax to Django's URLConf. It implements a declarative class-based syntax:# urls.py (née 'URLConf')from django.conf.urls import patternsfrom url_namespaces import (Namespace, View, Redirect, \ReverseRedirect, KeywordReverseRedirect)class MyOtherURLs(Namespace):""" URL namespaces are classes,the URLs they contain are propertiesof those classes. """class Meta:namespace = 'testapp:views'app_name = 'testapp'view_prefix = ''rss = View(r'^(?P<blog>[\w\-]+)/rss/?$','testapp.views.blogrss',arg='yo', other_arg='dogg')index = View(r'^(?P<blog>[\w\-]+)/$','testapp.views.blogpage')entry = View(r'^(?P<blog>[\w\-]+)/(?P<entry>[\w\-]+)/?$','testapp.views.blogentrypage')class MyURLs(Namespace):""" Namespaces can be nested """class Meta:namespace = 'testapp'app_name = 'testapp'view_prefix = ''pages = MyOtherURLs(r'^/pages/')elsewhere = Redirect(r'^/yodogg?',"http://www.yodogg.com/")root = ReverseRedirect(r'^/?','testapp:index', blog="test")entry_redirect = ReverseRedirect(r'^blog/(?P<blog>[\w\-]+)/(?P<entry>[\w\-]+)/?$','testapp:entry', blog="%(blog)s", entry="%(entry)s")entry_redirect_again = KeywordReverseRedirect(r'^blog/(?P<blog>[\w\-]+)/(?P<entry>[\w\-]+)/?$','testapp:entry')# These classes generate standard URL patterns# and use url(), reverse(), RegexURLResolver;# the project aims for compatibility with Django's# URLConf structures.urlpatterns = patterns('',MyURLs(r'^/?').connect('testapp'))Djano-URL-Namespaces implements a host of combinator objects, representing intuitive ideas e.g. `View`, `Redirect`, `Namespace` &c,which can be modularly rearranged without the worries incumbent in getting ones' hands dirty with the rather fragile Django-nativeURLConf syntax.At the time of writing the project is in a state of somewhat indeterminate disrepair; namespaces don't nest quite right, there's a lot of sketchy code commented out and not enough docstrings, etc. If this is the sort of thing that floats your boat, know that I never turn away an entertaining pull-request, indeed!
Package: django-url-or-relative-url-field
Django URL or Relative URL FieldThis package extends default Django URLField to support relative URLs.InstallationInstall the python package django-url-or-relative-url-field from pip:pip install django-url-or-relative-url-fieldAlternatively, you can install download or clone this repo and callpip install -e ..Add to INSTALLED_APPS in yoursettings.py:'url_or_relative_url_field',UsageAdd field to the model:fromdjango.dbimportmodelsfromurl_or_relative_url_field.fieldsimportURLOrRelativeURLFieldclassRedirect(models.Model):url=URLOrRelativeURLField()Now your model will accept both absolute and relative URLs into theurlfield.
Package: django-url-renditions
django-url-renditionsdjango-url-renditions allows to define and render renditions from django url fields. This works also pretty well withdjango-s3directfields.It comes with a GrapheneQuerythat enable renditions in your GraphQL schema.Installpip install django-url-renditionsAddurl_renditionsto yourINSTALLED_APPSDefine your modelfromdjango.dbimportmodelsfromurl_renditions.fieldsimportFileUrlWithRenditions# django-url-renditions comes with a simple image resizer method.# Look at the implementation if you need something more specificfromurl_renditions.resize_imageimportResizeImageclassTrack(models.Model):original_artwork=models.URLField()artwork=FileUrlWithRenditions(source='original_artwork',use_job_runner=True,#  if we want to queue the job with django_rqrenditions={'small':ResizeImage('80x80'),'medium':ResizeImage('300x300'),})That way, when aTrackmodel get created with anoriginal_artwork,artworkwill be automatically polulated with two renditions:smallandmedium.To access them, use:r=my_track.artwork.rendition_set.get(name='small')print('url:',r.href,'width:',r.width,'height:',r.height)Graphql with GrapheneAddurl_renditions.graphql_schema.Queryto your root query.importgrapheneimporturl_renditions.graphql_schema# noqaclassQuery(...url_renditions.graphql_schema.Query,graphene.ObjectType):passschema=graphene.Schema(query=Query)Then when you ask for{track(id:"VHJhY2s6OA=="){artwork{renditions{medium{hrefwidthheight}}}}}You get{"data":{"track":{"artwork":{"renditions":{"medium":{"href":"https://images.unsplash.com/photo-1474314170901-f351b68f544f","width":300,"height":300}}}}}}
Package: django-url-robots
Djangorobots.txtgenerator. Based on using decorateddjango.conf.urls.url.
It getsurlpatternsand replaces ambiguous parts by*.Installation & UsageThe recommended way to install django-url-robots is withpipInstall from PyPI witheasy_installorpip:pip install django-url-robotsAdd'url_robots'to yourINSTALLED_APPS:INSTALLED_APPS = (
    ...
    'url_robots',
    ...
    )Add url_robots view to your root URLconf:urlpatterns += [
    url(r'^robots\.txt$', url_robots.views.robots_txt),
    ]Describe rules by boolean keyword argumentrobots_allowusing for iturl_robots.utils.urlinsteaddjango.conf.urls.url:from url_robots.utils import url

urlpatterns += [
   url('^profile/private$', views.some_view, robots_allow=False),
   ]django-url-robotstested withDjango-1.8+. Encodes unicode characters by percent-encoding.SettingsIn this moment there are only one option to define template ofrobots.txtfile:urlpatterns += [
    url(r'^robots\.txt$', url_robots.views.robots_txt, {'template': 'my_awesome_robots_template.txt'}),
    ]Examplerobots_template.txt:User-agent: *
Disallow: /*  # disallow all
{{ rules|safe }}urls.py:from django.conf.urls import include

urlpatterns = [
    url(r'^profile', include('url_robots.tests.urls_profile')),
]urls_profile.py:from url_robots.utils import url

urlpatterns = [
    url(r'^s$', views.some_view, name='profiles', robots_allow=True),
    url(r'^/(?P<nick>\w+)$', views.some_view),
    url(r'^/(?P<nick>\w+)/private', views.some_view, name='profile_private', robots_allow=False),
    url(r'^/(?P<nick>\w+)/public', views.some_view, name='profile_public', robots_allow=True),
    ]Resulting robots.txt:User-agent: *
Disallow: /*  # disallow all
Allow: /profiles$
Disallow: /profile/*/private*
Allow: /profile/*/public*
Package: django-urls
What isdjango_urls?It is flask style urls for django.How to use it?# app/urls.py or where-ever you want really.fromdjango_urlsimportUrlManagerapp_urls=UrlManager(views_root='dotted.path.to.app.views.module')app_urls.extend(extra_urls_list)# app/views/foo.pyfromapp.urlsimportapp_urls@app_urls.path('path/',name='MyView',importance=5)# the bigger the importance higher in the list it goesclassMyView(View):...@app_urls.re_path('path2/',name='my_view',importance=1)defmy_view(request):...# project/urls.pyfromdjango.urlsimportinclude,pathfromapp.urlsimportapp_urlsurl_patterns=[path('some_path/',include(app_urls.url_patterns))]That's it, not too much setup, right?
Package: django-url-shortener-app
=====
Django URL ShortenerDjango URL Shortener is a Django app to to include URL Shortening feature in your Django ProjectDetailed documentation is in the "docs" directory.Quick startAdd "django_url_shortener" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [
...
'django_url_shortener',
]Include the polls URLconf in your project urls.py like this::path('s/', include('django_url_shortener.urls')),Runpython manage.py migrateto create the polls models.[Optional] Upate configs in settings.py
SHORTCODE_MIN = 4
SHORTCODE_MAX = 20
BASE_URL = "https://mysite.com"Import shorten_url method
from django_url_shortener.utils import shorten_urlShorten your URLcreated, short_url = shorten_url("https://github.com/rishav00a/django_url_shortener")
created, short_url = shorten_url("https://github.com/rishav00a/django_url_shortener/issues","xyzw")
Package: django-url-shortening
django-url-shorteningA custom URL shortening app for Django with API.UsageAddurlshorteningapp to yourINSTALLED_APPSand domigrateWire up the redirect view by adding to your URLconf('^linkshortening/', include('urlshortening.urls'))Add settings (more about parameters further)INITIAL_URL_LEN = 6
RETRY_COUNT = 5
SHORT_URL_PATH = 'http://example.com/short-prefix/'
REDIRECT_PREFIX = 'r'Now you can use API to make short linksPOST linkshortening/short/With json data{"full_url":"http://example.com/a/b/c/d/e"}And get response{"data": {
    "short_id": "123456",
    "short_url_path": "http://example.com/short-prefix/"
 }, "error": ""}You could also useurlshorteningright from codefrom urlshortening.models import get_short_url, invalidate_url, get_full_urlurl = "http://example.com/a/b/c/d/e"
short_url = get_short_url(url) # Url object
print(short_url.short_id) # id for short urlfull_url = get_full_url(short_url.short_id) # Url object
print(full_url.url) # "http://example.com/a/b/c/d/e"# You could also invalidate url
invalidate_url(full_url.short_id)APIGet short linkURL/short/Method:POSTData Paramsfull_urlSuccess Response:Code:200Content:{ data: { "short_url_path": "000001" }, error: "" }Error Response:Code:400Content:{ error : "full_url is empty" }Code:400Content:{ error : "full_url is too long" }Get full linkURL/expand/:short_id/Method:GETURL Paramsshort_id=[string]Success Response:Code:200Content:{ error : "", data: { full_url:"http://example.com/to-000001"}}Error Response:Code:404Content:{ error : "Link is expired" }Code:404Content:{ error : "Urldoesn\'texist" }Get redirectURL/REDIRECT_PREFIX/expand/:short_id/Method:GETURL Paramsshort_id=[string]Success Response:Code:302Error Response:Code:404Content:{ error : "Link is expired" }Code:404Content:{ error : "Urldoesn\'texist" }Invalidate urlURL/invalidate/Method:POSTData Paramsshort_idSuccess Response:Code:200Content:{ error : "", data: { "short_id": "000001", "invalidated": "true" } }Error Response:Code:400Content:{ error : "short_id is empty" }Code:400Content:{ error : "Link is already expired" }Code:404Content:{ error : "Urldoesn\'texist" }SettingsAvailable settings are:INITIAL_URL_LENInitial length of short id for url. Once you get more short id’s than
is possible in all combinations ofINITIAL_URL_LENsymbols it
will increase by oneRETRY_COUNTHow many times do we to check before increasingINITIAL_URL_LEN.SHORT_URL_PATHUrl that will be returned withshort_idonPOST linkshortening/short/request. It might help you to
construct full url.REDIRECT_PREFIXSelect prefix to use redirect links. For exampleREDIRECT_PREFIX="r"and we get redirect links with format/r/expand/{short_id}/
Package: django-urlshortner
Django URL ShortnerA set of utils to build custom fully-functional Django URL Shortner. This library helps you build a custom URL Shortner service for your project without relying on external services likebitlyQuick StartInstallationDjango UrlShortner is available at thePython Packaging Indexso you can Install it usingpippipinstalldjango-urlshortnerPlease dont mistake the spelling withdjango-urlshortenerwhen installing. The name does not have anein the word shortner. Itsdjango-urlshortnernotdjango-urlshortenerAfter you should add theurlshortnerapp to yourINSTALLED_APPSinsettings.pyConfigurationINSTALLED_APPS=[# ...."urlshortner"]Then you migrate the models to your databasepython3manage.pymigrateLastly add the routes to your URLConf in yoururls.pyof your project.url_patterns=[# ...path("r/",include("urlshortner.urls")),]Now you are good to go.UsageThe library provides a list of utils to create shortened urls.To create a short version of a url use theshorten_urlfunction fromurlshortner.utilsmodule# python3 manage.py shellfromurlshortner.utilsimportshorten_urlurl_route=shorten_url("https://github.com/jim-junior/django-urlshortner",is_permanent=False)print(url_route)# >>> 0ee3f0You can now navigate to you the route that you assigned tourlshortner.urlsin your URLConf add the returned value att the end of the url. In this case it would behttp://localhost:8000/r/0ee3f0/and this would redirect you to the right URLSometimes you want to create a custom URL. For example you want to create a short link for a blog about your new product and you want a url that is easy to remember. You can add this easily by adding thevalueargument to theshorten_urlfunctionfromurlshortner.utilsimportshorten_urlurl_route=shorten_url("https://myblog.com/blog/2022/10/10/..../my-new-product",value="NewProduct"is_permanent=False)You can now navigate tohttps://localhost/r/NewProductand It will redirect youLicence MITCopyright ©Beingana JIm Junior, 2022
Package: django-url-simplify
Url Simplify is a simple Django app which generates simplified base62 urls
from regular ones.Detailed documentation is in the “docs” directory.Quick startAddurl_simplifyto your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'url_simplify',
]Include theurl_simplifyURLconf in your project urls.py like this:path('url_simplify/', include('url_simplify.urls')),Runpython manage.py migrateto create the url_simplify models.Start the development server and visithttp://127.0.0.1:8000/admin/to create a url_simplify (you’ll need the Admin app enabled).Visithttp://127.0.0.1:8000/url_simplify/to start generating simplified urls.
Package: django-urls-map
This is a simple Django app to embed a management command that will display the urls map of your project.The urls map is an agregated list of urls from all installed apps in your settings.InstallAdd it to your installed apps in the settings :INSTALLED_APPS = (
    ...
    'django_urls_map',
    ...
)UsageTo display the full url list, just do :./manage.py urlmapNote that this will include also all the Django admin urls if enabled, it’s a little verbose.So if needed you can exclude some paths, like for the Django admin :./manage.py urlmap --exclude="/admin/"And this will render something like that (depends on what apps you have installed) :* /media/(?P<path>.*) Unnamed
* /
* /static\/(?P<path>.*) Unnamed
* /slideshows/
* /slideshows/show_slides/(?P<slug>[-\w]+)/ show_slides
* /slideshows/random_slide/(?P<slug>[-\w]+)/ random_slide
* /ckeditor/editor_site_templates.js ckeditor-editor-site-templates
* /admin_tools/
* /admin_tools/menu/
    * /admin_tools/menu/add_bookmark/ admin-tools-menu-add-bookmark
    * /admin_tools/menu/edit_bookmark/(?P<id>.+)/ admin-tools-menu-edit-bookmark
    * /admin_tools/menu/remove_bookmark/(?P<id>.+)/ admin-tools-menu-remove-bookmark
* /admin_tools/dashboard/
    * /admin_tools/dashboard/set_preferences/(?P<dashboard_id>.+)/ admin-tools-dashboard-set-preferences
* /accounts/
* /accounts/activate/complete/ registration_activation_complete
* /accounts/activate/(?P<activation_key>\w+)/ registration_activate
* /accounts/register/ registration_register
* /accounts/register/complete/ registration_complete
* /accounts/register/closed/ registration_disallowed
* /accounts/login/ auth_login
* /accounts/password/change/ auth_password_change
* /accounts/password/reset/ auth_password_reset
* /accounts/password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/ auth_password_reset_confirm
* /accounts/
    * /accounts/login/ auth_login
    * /accounts/logout/ auth_logout
    * /accounts/password/change/ auth_password_change
    * /accounts/password/change/done/ auth_password_change_done
    * /accounts/password/reset/ auth_password_reset
    * /accounts/password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/ auth_password_reset_confirm
    * /accounts/password/reset/complete/ auth_password_reset_complete
    * /accounts/password/reset/done/ auth_password_reset_done
* /en-us/
* /en-us/
    * /en-us/ pages-root
    * /en-us/(?P<slug>[0-9A-Za-z-_.//]+)/ pages-details-by-slugThis sample was generated from a Django project that includes “Django cms”, “Django admin tools”, “emencia-django-slideshows
“ and a custom app based on “Django registration”. Note that the render uses colored terminal output (to assure some readability).You can many path to exclude, the paths is raw strings (not Regex) and are only used with the “startswith” method, this means it will only match your paths from the start of urls.
Package: django-urls-templatetag
Descriptiondjango-urls-templatetagallows you to reverse django URLs within JavaScript exactly as you do from within Python using the standardreversefunction.Installation and usageFrom your django virtual environment, runpip install django-urls-templatetag, adddjango_urls_templatetaginside yourINSTALLED_APPS, then, in yourbase.htmltemplate (or any template which defines your JavaScript includes in the HTML<head>tag), add{% load django_urls %}and then include{% django_urls_script 'url_namespace1' 'url_namespace2' ... %}somewhere inside the<head>tag of your HTML template,aboveany JavaScript library or code which will make use of this. When you include thedjango_urls_scripttemplate tag, you will need to specify which namespaces you want reversed. This is not an automatic process because that could introduce security vulnerabilities by exposing all available URL endpoints. With the template tag included, you can now use areverse_urlfunction within JavaScript.ExampleSay we have a project which has URLs under an "api" namespace and URLs under a "blog" namespace. In django, we would reverse these withreverse("api:blog_post_list")orreverse("blog:index")for example. To get the same effect in JavaScript, I would include{% django_urls_script 'api' 'blog' %}inside my<head>tag in my template. Then, to reverse the URLs from inside JavaScripr, I would doreverse_url("api:blog_post_list")orreverse_url("blog:index"). Both of these would return as a string the URLs of either endpoint.Reversing URLs with keyword arguments is also possible. Simply provide the keyword arguments as a JavaScript object as a second argument. An example might look like this:reverse_url("blog:blog_post_detail", {pk: 55}). Easy and simple.
Package: django-urltags
Django URLtags is a collection of template tags and filters for manipulating URLs or adding some convenience methods for common practices.add_qs_paramUsage:{% add_qs_param url varname value %}This tag intelligently adds or replaces the query string parametervarnameand assigns itvalue.url,varname, andvaluecan be static values or variablesExamplesAdding a single query string parameter{%add_qs_paramhttp://example.com/q1%}generates:http://example.com/?q=1Adding a query string parameter to a URL with a query string.{%add_qs_paramhttp://example.com/?sort=ascq1%}generates:http://example.com/?sort=asc&q=1Adding a query string parameter to a URL that already has that parameter.{%add_qs_paramhttp://example.com/?q=5q1%}generates:http://example.com/?q=1Adding a query string parameter to a URL that has a page fragment.{%add_qs_paramhttp://example.com/#gohereq1%}generates:http://example.com/?q=1#gohereadd_fragmentUsage:{{ url|add_fragment:variable }}or{{url|add_fragment:"fragment"}}This tag intelligently adds or replaces the URL fragment. You can pass a variable as the parameter toadd_fragmentor a static value. You must quote static values.Example{{url|add_fragment:"gohere"}}generates:http://example.com/#gohereabsurlJust like Django’surl tagbut adds the domain of the current site.linkUsage:{{ object|link }}Outputs the object in a anchor tag which is the equivalent of<ahref="{{object.get_absolute_url}}">{{object}}</a>
Package: django-urr
django-urrDjango URL resolver utilitiesThis package aims to make it easier to introspect and possibly manipulate
the URL resolver(s) in Django projects.We use urr to auto-generate smoke tests for all URLs in the project,
but you might come up with other uses. Who knows!InstallationInstall the package usingpip installor similar.To use the management command(s), also adddjango_urrto your project'sINSTALLED_APPS.urr_listManagement CommandYou can use theurr_listmanagement command to generate
a machine-readable (but human-greppable) list of URLs in your project.By default,urr_listoutputsJSON Lines (jsonl), with each
route on a line of its own; this is greppable with standard tools.
If you'd prefer, you can also directurr_listto output a single JSON
array with--format=json.Each route is an object (dict) has the following keys:groups– the named capture groups (route arguments).
For unnamed groups, these are named_0,_1, etc. by Django.name– the name of the route, if anynamespace– the namespace of the route, if anypath– the path of the route, as a Python percent format stringpattern– the regex to match the pathProgrammatic APIThedjango_urr.extract_urls()function
traverses the tree of URL patterns and returns an iterator ofdjango_urr.extract.URLEntryobjects in original mounting order.
Package: django-usd2currency
Convert value from usd to currencySimple and free usd2currency convert utils,
by caching free-limited-api from apilayer.comQuick startInstall::pip install django-usd2currencyAdd "django_usd2currency" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [
   ...
   'django_usd2currency',
   ]
   # Get free api from https://currencylayer.com/signup/free
   APILAYER_ACCESS_KEY = 'xxxxxxxxxxx'Start to use it in codefrom django_usd2currency.utils import usd2currency

   print(usd2currency(12, currency='CNY'))Useredis as cache backendto lock in the multiprocess env.TODO:write test