django-py-reverse


Namedjango-py-reverse JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/robertpro/django-py-reverse
SummaryPython URL handling for Django (based on django-js-reverse)
upload_time2024-09-09 16:37:11
maintainerRoberto Meza
docs_urlNone
authorRoberto Meza
requires_python<4.0,>=3.9
licenseMIT
keywords django url reverse js python py
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-py-reverse

> 

[![Latest Version on PyPI](https://img.shields.io/pypi/v/django_py_reverse.svg)](https://pypi.python.org/pypi/django_py_reverse/)
[![Supported Implementations](https://img.shields.io/pypi/pyversions/django_py_reverse.svg)](https://pypi.python.org/pypi/django_py_reverse/)
![Build Status](https://github.com/robertpro/django-py-reverse/actions/workflows/test.yaml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/https://github.com/robertpro/django-py-reverse/badge.svg?branch=master)](https://coveralls.io/github/https://github.com/robertpro/django-py-reverse?branch=master)
[![Built with PyPi Template](https://img.shields.io/badge/PyPi_Template-v0.6.1-blue.svg)](https://github.com/christophevg/pypi-template)


## Installation

```bash
pip install django_py_reverse

# or using poetry
poetry add django_py_reverse
```

## Usage

```python
from django_py_reverse import Urls

API_ENDPOINT = "https://example.com/api/v1"
data_urls = {
    "urls": [
        [
            "account_confirm_email",
            [["accounts/confirm_email/%(key)s/", ["key"]]],
        ],
        ["account_delete", [["accounts/delete/", []]]],
        ["account_password_reset", [["es/accounts/password/reset/", []]]],
        [
            "account_password_reset_token",
            [
                [
                    "accounts/password/reset/%(uidb36)s-%(token)s/",
                    ["uidb36", "token"],
                ]
            ],
        ],
    ],
    "prefix": "/",
}

urls = Urls(data=data_urls, url_prefix=API_ENDPOINT).factory()

print(urls['account_confirm_email'](key="123"))
print(urls['account_delete']())
print(urls['account_password_reset']())
print(urls['account_password_reset_token'](uidb36="123", token="456"))

# Output:
# https://example.com/api/v1/accounts/confirm_email/123/
# https://example.com/api/v1/accounts/delete/
# https://example.com/api/v1/es/accounts/password/reset/
# https://example.com/api/v1/accounts/password/reset/123-456/
```

### Include JS Style

```python
urls = Urls(data=data_urls, url_prefix=API_ENDPOINT, include_js_style=True).factory()

print(urls['accountConfirmEmail'](key="123"))
print(urls['accountDelete']())
print(urls['accountPasswordReset']())
print(urls['accountPasswordResetToken'](uidb36="123", token="456"))

# Output:
# https://example.com/api/v1/accounts/confirm_email/123/
# https://example.com/api/v1/accounts/delete/
# https://example.com/api/v1/es/accounts/password/reset/
# https://example.com/api/v1/accounts/password/reset/123-456/
```

### You can get the urls from your current django & django-js-reverse project more info [here](https://pypi.org/project/django-js-reverse/)

```bash
wget ${API_ENDPOINT}/jsreverse/json/ -O data/urls.json
```

### Then on your python project

```python
import json
from django_py_reverse import Urls

API_ENDPOINT = "https://example.com/api/v1"

with open("data/urls.json") as f:
    data_urls = json.load(f)

urls = Urls(data=data_urls, url_prefix=API_ENDPOINT).factory()
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/robertpro/django-py-reverse",
    "name": "django-py-reverse",
    "maintainer": "Roberto Meza",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": "the@robertpro.dev",
    "keywords": "django, url, reverse, js, python, py",
    "author": "Roberto Meza",
    "author_email": "the@robertpro.dev",
    "download_url": "https://files.pythonhosted.org/packages/90/aa/1cd0ff22e0ff66fe55bb8f7e1207cf4f7debce4ca54092fcadf1a1993715/django_py_reverse-1.0.1.tar.gz",
    "platform": null,
    "description": "# django-py-reverse\n\n> \n\n[![Latest Version on PyPI](https://img.shields.io/pypi/v/django_py_reverse.svg)](https://pypi.python.org/pypi/django_py_reverse/)\n[![Supported Implementations](https://img.shields.io/pypi/pyversions/django_py_reverse.svg)](https://pypi.python.org/pypi/django_py_reverse/)\n![Build Status](https://github.com/robertpro/django-py-reverse/actions/workflows/test.yaml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/https://github.com/robertpro/django-py-reverse/badge.svg?branch=master)](https://coveralls.io/github/https://github.com/robertpro/django-py-reverse?branch=master)\n[![Built with PyPi Template](https://img.shields.io/badge/PyPi_Template-v0.6.1-blue.svg)](https://github.com/christophevg/pypi-template)\n\n\n## Installation\n\n```bash\npip install django_py_reverse\n\n# or using poetry\npoetry add django_py_reverse\n```\n\n## Usage\n\n```python\nfrom django_py_reverse import Urls\n\nAPI_ENDPOINT = \"https://example.com/api/v1\"\ndata_urls = {\n    \"urls\": [\n        [\n            \"account_confirm_email\",\n            [[\"accounts/confirm_email/%(key)s/\", [\"key\"]]],\n        ],\n        [\"account_delete\", [[\"accounts/delete/\", []]]],\n        [\"account_password_reset\", [[\"es/accounts/password/reset/\", []]]],\n        [\n            \"account_password_reset_token\",\n            [\n                [\n                    \"accounts/password/reset/%(uidb36)s-%(token)s/\",\n                    [\"uidb36\", \"token\"],\n                ]\n            ],\n        ],\n    ],\n    \"prefix\": \"/\",\n}\n\nurls = Urls(data=data_urls, url_prefix=API_ENDPOINT).factory()\n\nprint(urls['account_confirm_email'](key=\"123\"))\nprint(urls['account_delete']())\nprint(urls['account_password_reset']())\nprint(urls['account_password_reset_token'](uidb36=\"123\", token=\"456\"))\n\n# Output:\n# https://example.com/api/v1/accounts/confirm_email/123/\n# https://example.com/api/v1/accounts/delete/\n# https://example.com/api/v1/es/accounts/password/reset/\n# https://example.com/api/v1/accounts/password/reset/123-456/\n```\n\n### Include JS Style\n\n```python\nurls = Urls(data=data_urls, url_prefix=API_ENDPOINT, include_js_style=True).factory()\n\nprint(urls['accountConfirmEmail'](key=\"123\"))\nprint(urls['accountDelete']())\nprint(urls['accountPasswordReset']())\nprint(urls['accountPasswordResetToken'](uidb36=\"123\", token=\"456\"))\n\n# Output:\n# https://example.com/api/v1/accounts/confirm_email/123/\n# https://example.com/api/v1/accounts/delete/\n# https://example.com/api/v1/es/accounts/password/reset/\n# https://example.com/api/v1/accounts/password/reset/123-456/\n```\n\n### You can get the urls from your current django & django-js-reverse project more info [here](https://pypi.org/project/django-js-reverse/)\n\n```bash\nwget ${API_ENDPOINT}/jsreverse/json/ -O data/urls.json\n```\n\n### Then on your python project\n\n```python\nimport json\nfrom django_py_reverse import Urls\n\nAPI_ENDPOINT = \"https://example.com/api/v1\"\n\nwith open(\"data/urls.json\") as f:\n    data_urls = json.load(f)\n\nurls = Urls(data=data_urls, url_prefix=API_ENDPOINT).factory()\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python URL handling for Django (based on django-js-reverse)",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/robertpro/django-py-reverse",
        "Repository": "https://github.com/robertpro/django-py-reverse"
    },
    "split_keywords": [
        "django",
        " url",
        " reverse",
        " js",
        " python",
        " py"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa04d744a40ee5c886d85a10921f8de34c776616e45dfe09fa42cf11170c60b6",
                "md5": "b2e39bff34de6d3d95c34497faa830d9",
                "sha256": "561d8df8428354726306c39a90635d4760658b368add622845e2ef2b2d02629a"
            },
            "downloads": -1,
            "filename": "django_py_reverse-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b2e39bff34de6d3d95c34497faa830d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 5085,
            "upload_time": "2024-09-09T16:37:09",
            "upload_time_iso_8601": "2024-09-09T16:37:09.987716Z",
            "url": "https://files.pythonhosted.org/packages/fa/04/d744a40ee5c886d85a10921f8de34c776616e45dfe09fa42cf11170c60b6/django_py_reverse-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90aa1cd0ff22e0ff66fe55bb8f7e1207cf4f7debce4ca54092fcadf1a1993715",
                "md5": "970c25e68f770ca3f62bb8a58263d754",
                "sha256": "89300d7948819f2cbe2e009c7f2cdebaa0dd57abdc2f1890f2fe25632d31a5a9"
            },
            "downloads": -1,
            "filename": "django_py_reverse-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "970c25e68f770ca3f62bb8a58263d754",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 3877,
            "upload_time": "2024-09-09T16:37:11",
            "upload_time_iso_8601": "2024-09-09T16:37:11.513143Z",
            "url": "https://files.pythonhosted.org/packages/90/aa/1cd0ff22e0ff66fe55bb8f7e1207cf4f7debce4ca54092fcadf1a1993715/django_py_reverse-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-09 16:37:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "robertpro",
    "github_project": "django-py-reverse",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-py-reverse"
}
        
Elapsed time: 0.40016s