Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hapytex/django-path-converters

A collection of utility path converters.
https://github.com/hapytex/django-path-converters

django django-urls parsing path url

Last synced: 21 days ago
JSON representation

A collection of utility path converters.

Awesome Lists containing this project

README

        

# `django-path-converters`

An underestimated part of Django is its *path converters*: a way to define a certain pattern for a URL once, together with
mapping functions from and to that pattern.

These can then be plugged in into the URL paths one defines, and thus makes querying more convenient. The pattern can also
often be defined more restricted, since the work to define a pattern is done once, and is thus not very cumbersome.

This package aims to provide some general purpose path converters. Probably the most sophisticated one are lazy model
object loads: these will *not* evaluate an object, unless it is necessary, and thus therefore could save some queries.

## Overview of the defined path converters



name
to_types
examples
regex
from_types




<auth.group:…>
<class 'django.contrib.auth.models.Group'>

[0-9]+
<class 'django.contrib.auth.models.Group'>


<auth.group.id:…>
<class 'django.contrib.auth.models.Group'>

[0-9]+
<class 'django.contrib.auth.models.Group'>


<auth.group.name:…>
<class 'django.contrib.auth.models.Group'>

[^/]+
<class 'django.contrib.auth.models.Group'>


<auth.permission:…>
<class 'django.contrib.auth.models.Permission'>

[0-9]+
<class 'django.contrib.auth.models.Permission'>


<auth.permission.id:…>
<class 'django.contrib.auth.models.Permission'>

[0-9]+
<class 'django.contrib.auth.models.Permission'>


<auth.user:…>
<class 'django.contrib.auth.models.User'>

[0-9]+
<class 'django.contrib.auth.models.User'>


<auth.user.id:…>
<class 'django.contrib.auth.models.User'>

[0-9]+
<class 'django.contrib.auth.models.User'>


<auth.user.username:…>
<class 'django.contrib.auth.models.User'>

[^/]+
<class 'django.contrib.auth.models.User'>


<autoslug:…>
<class 'str'>
this-is-a-slug
slugifying-this-str
[-a-zA-Z0-9_]+
<class 'str'>
<class 'django.db.models.base.Model'>


<autoslugunicode:…>
<class 'str'>
this-is-a-slug
slugifying-this-str
[-a-zA-Z0-9_]+
<class 'str'>
<class 'django.db.models.base.Model'>


<bool:…>
<class 'bool'>
True
False
1
0
T
F
on
oFF
yes
NO
[Yy]([Ee][Ss])?|[Tt]([Rr][Uu][Ee])?|[Oo][Nn]|1|[Ff]([Aa][Ll][Ss][Ee])?|[Nn][Oo]?|[Oo][Ff][Ff]|0
<class 'object'>


<contenttype:…>
<class 'django.contrib.contenttypes.models.ContentType'>

[0-9]+
<class 'django.contrib.contenttypes.models.ContentType'>


<contenttype.id:…>
<class 'django.contrib.contenttypes.models.ContentType'>

[0-9]+
<class 'django.contrib.contenttypes.models.ContentType'>


<contenttypes.contenttype:…>
<class 'django.contrib.contenttypes.models.ContentType'>

[0-9]+
<class 'django.contrib.contenttypes.models.ContentType'>


<contenttypes.contenttype.id:…>
<class 'django.contrib.contenttypes.models.ContentType'>

[0-9]+
<class 'django.contrib.contenttypes.models.ContentType'>


<date:…>
<class 'datetime.date'>
2023-01-21
[0-9]{4}[-](?:0?[1-9]|1[0-2])-(?:0?[1-9]|[12][0-9]|3[01])
<class 'datetime.datetime'>
<class 'datetime.date'>


<daterange:…>
<class 'django_path_converters.converters.daterange'>
1958-3-25/2019-11-25
(?P<from_date>[0-9]{4}[-](?:0?[1-9]|1[0-2])-(?:0?[1-9]|[12][0-9]|3[01]))/(?P<to_date>[0-9]{4}[-](?:0?[1-9]|1[0-2])-(?:0?[1-9]|[12][0-9]|3[01]))
typing.Iterable


<datetime:…>
<class 'datetime.datetime'>
2023-01-24T19:21:18Z
2023-01-24T19:21:18+00:00
2023-01-24T19:47:58
[0-9]{4}[-](?:0?[1-9]|1[0-2])-(?:0?[1-9]|[12][0-9]|3[01])T(?:[0-1]\d|2[0-4])[:]?[0-5][0-9][:]?[0-5][0-9](?:Z|[+-](?:[0-1]\d|2[0-4])[:]?[0-5][0-9])?
<class 'datetime.datetime'>
<class 'datetime.date'>


<django_path_converters.group:…>
<class 'django_path_converters.models.Group'>

[0-9]+
<class 'django_path_converters.models.Group'>


<django_path_converters.group.id:…>
<class 'django_path_converters.models.Group'>

[0-9]+
<class 'django_path_converters.models.Group'>


<django_path_converters.group.level:…>
<class 'django_path_converters.models.Group'>
-12
14
25
[+-]?[0-9]+
<class 'django_path_converters.models.Group'>


<eager_auth.group:…>
<class 'django.contrib.auth.models.Group'>

[0-9]+
<class 'django.contrib.auth.models.Group'>


<eager_auth.group.id:…>
<class 'django.contrib.auth.models.Group'>

[0-9]+
<class 'django.contrib.auth.models.Group'>


<eager_auth.group.name:…>
<class 'django.contrib.auth.models.Group'>

[^/]+
<class 'django.contrib.auth.models.Group'>


<eager_auth.permission:…>
<class 'django.contrib.auth.models.Permission'>

[0-9]+
<class 'django.contrib.auth.models.Permission'>


<eager_auth.permission.id:…>
<class 'django.contrib.auth.models.Permission'>

[0-9]+
<class 'django.contrib.auth.models.Permission'>