{ "info": { "author": "Christopher Ventura", "author_email": "venturachrisdev@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Environment :: Plugins", "Framework :: Django", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Pre-processors" ], "description": "![DjUrl - Django urls](/djurlheader.png) [![Build Status](https://travis-ci.org/venturachrisdev/djurl.svg?branch=master)](https://travis-ci.org/venturachrisdev/djurl)\n===\nSimple yet helpful library for writing Django urls by an easy, short an intuitive way.\n\nWhy should I use DjUrl?\n---\nDjango routing urls aren't easy to deal with, regular expressions can become a nightmare sometimes. Just imagine dealing with such routes in your `django app`:\n```python\nfrom django.conf.urls import url\nfrom core import BlogView, SinglePostView, SearchResultsView, ArchiveView\n\nurlpatterns = [\n\t# => /blog/\n\turl(r'^blog/$', BlogView.as_view(), name=\"blog\"),\n\t# => /blog/5\n\turl(r'^blog/(?P[0-9]+)/$', SinglePostView.as_view(), name=\"singlepost\"),\n\t# => /blog/search/sometitle\n\turl(r'^blog/search/(?P[A-Za-z0-9_-]+)/$', SearchResultsView.as_view(), name=\"search\"),\n\t# => /blog/archive/2017/02/12\n\turl(r'^blog/archive/(?P[0-9]{4}-(0?([1-9])|10|11|12)-((0|1|2)?([1-9])|[1-3]0|31))/$',\n\t\tArchiveView.as_view(), name=\"archive\")\n]\n```\nThat's too much work and you lost me in those regex. With **DjUrl** this comes easy, you just need to *express what you want*, **DjUrl will handle the regular expressions for you**:\n\n```python\nfrom djurl import url\nfrom core import BlogView, SinglePostView, SearchResultsView, ArchiveView\n\nurlpatterns = [\n\turl('/blog', BlogView, name=\"blog\"),\n\turl('/blog/:id', SinglePostView, name=\"singlepost\"),\n\turl('/blog/search/:query', SearchResultsView, name=\"search\"),\n\turl('/blog/archive/:date', ArchiveView, name=\"archive\")\n]\n```\nNo regex, just clean paths and param names. You can now pass the regex work to DjUrl and concentrate in the *bussiness logic*. It saves you a lot of time and code. *You don't need to worry about the routes anymore*. **Note you don't need to call `as_view` in your CBV's.** DjUrl does this for you as well.\n\nUsage\n---\nNow you know what you should use `DjUrl`, It's time to learn how to use it. DjUrl has a list of known/default pattern that you can use in your routes, these are:\n\n* `id`: A secuence of characters from 0 to 9. Ej: `1, 12, 454545, 8885500, 8`\n* `pk`: A primary key, it's like `id` but needed for `Class Based Views`.\n* `page`: falls in the same category, but you'd use `page` for a better param name.\n* `slug`: A simple string (alphanumeric characters).\n* `query`: A search parameter. It allows some special characters that *slug* doesn't. Ex: `hello%20word`, `don%27t_quote-me`\n* `day`: A number between 01,..., 31.\n* `month`: A number between 01,...,12.\n* `year`: A four digits number: `1998, 2017, 2018, 3015, 2020, 1406...`\n* `date`: An expression with `year-month-day` format: `2017-06-23, 1998-10-20, 1492-10-12`\n* `filename`: An expression with `*.\\w{2,4}` format: `index.js`, `detail.html`, `'my_book.pdf'`, `'dfj358h-g9854-fn84n4.tmp'`\n* `UUID`: *Universally unique identifier* is a 128-bit number used to identify information in computer systems. Use a format as `xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx`. Ex: `123e4567-e89b-12d3-a456-426655440000`\n\nThat means, wherever you put `/:id` you can use it in your view as param (named `id`).\n```python\nurl('post/:pk/comment/:id', myview, name=\"post_comment\")\n```\nYour view:\n```python\ndef myview(request, pk, id):\n\t# Use `pk` (post's) and `id` (comment's)\n```\n\nBut what if I have two or more id's, or two slugs? What if I wanted to use a custom name for my id's? - Ok, you can use custom names if you end it with `_` + the pattern type. - What?...\n```python\nurl('post/:post_pk/comment/:comment_id', myview, ...)\n# ...\ndef myview(request, post_pk, comment_id):\n\t# `post_pk` is parsed as a :pk and `comment_id` like an :id\n\n```\nYeah, it sounds good!, but... What if I wanted to use my own patterns? - Easy, any world in the path is of type `:slug` by default, but if you need a custom pattern you can register many as you want:\n```python\nfrom djurl import url, register_pattern\nregister_pattern('hash', '[a-f0-9]{9}')\n# parsed as slug\nurl('/:user', myUserView),\n# custom pattern\nurl('/:hash', myview),\n```\n\nIf you have questions, visit our [FAQ's](FAQ.md) or open an *issue*.\n\nInstall\n---\nIf you want to have fun with this library and integrate it to your project, just type in your terminal:\n```\n$ pip install djurl\n```\nor, clone the repo and type:\n```\n$ python setup.py install\n```\nEnjoy it!\n\nTesting\n---\nClone the repo and run Djurl tests by:\n```\n$ python setup.py test\n```\n\nContributions\n---\nIf you've found a bug/error or just have questions, feel free to open an **issue**. And, **Pull requests** are welcome as well.\nDon't forget to add your name to [CONTRIBUTORS.md](CONTRIBUTORS.md)\n\nLicense\n=======\n\n Copyright 2017 Christopher Ventura\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/venturachrisdev/djurl", "keywords": "django url urlparse web python regex", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "djurl", "package_url": "https://pypi.org/project/djurl/", "platform": "", "project_url": "https://pypi.org/project/djurl/", "project_urls": { "Homepage": "https://github.com/venturachrisdev/djurl" }, "release_url": "https://pypi.org/project/djurl/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Simple yet helpful library for writing Django urls by an easy, short an intuitive way.", "version": "0.2.0" }, "last_serial": 3001766, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "dcfab90ec1de6bc7c88d9609c2e071cd", "sha256": "e46d471e23b165410ebb4f43ca5728c6edd177718f79d109f563c84b511970ec" }, "downloads": -1, "filename": "djurl-0.1.1.tar.gz", "has_sig": false, "md5_digest": "dcfab90ec1de6bc7c88d9609c2e071cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4301, "upload_time": "2017-06-23T06:58:08", "url": "https://files.pythonhosted.org/packages/8d/81/c89e55e52ab4967fee221ada392765645dc22f2c10766483b0f06222a38d/djurl-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "d410efb9e0e543016eb4371150a1fdd8", "sha256": "afa618993b2c603f2eb4368faefc13ea371930820a1d0ed35a796d8082670ff3" }, "downloads": -1, "filename": "djurl-0.1.2.tar.gz", "has_sig": false, "md5_digest": "d410efb9e0e543016eb4371150a1fdd8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4775, "upload_time": "2017-06-24T03:18:32", "url": "https://files.pythonhosted.org/packages/6c/72/f658a3d50f1fb65a15cc6a0910e885be8f94514496c5a6302e0f4b9df65d/djurl-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "d6e62c95f06eac3ba1bce5d3ebd439b6", "sha256": "83afc09ff7eed9e68d7a2865f258bfb90bab1e60bdc19e51a3c6a23eace108a6" }, "downloads": -1, "filename": "djurl-0.1.3.tar.gz", "has_sig": false, "md5_digest": "d6e62c95f06eac3ba1bce5d3ebd439b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5038, "upload_time": "2017-06-25T21:58:08", "url": "https://files.pythonhosted.org/packages/e4/66/01846b407af1aeddf6b59b0f7a16b818841470c58a20debed4d449fa9e81/djurl-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "ae630e362906a12d0c4c53534490cb90", "sha256": "4fc7d5a667bb3dc6e348ed540f5001f5267481c453d1ad6ee5826121e78d59ae" }, "downloads": -1, "filename": "djurl-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ae630e362906a12d0c4c53534490cb90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5553, "upload_time": "2017-07-05T19:34:31", "url": "https://files.pythonhosted.org/packages/fc/91/a00997b51f7abcc9e0b76fb2bdcac64410492e49c29af099a11907636a4a/djurl-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ae630e362906a12d0c4c53534490cb90", "sha256": "4fc7d5a667bb3dc6e348ed540f5001f5267481c453d1ad6ee5826121e78d59ae" }, "downloads": -1, "filename": "djurl-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ae630e362906a12d0c4c53534490cb90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5553, "upload_time": "2017-07-05T19:34:31", "url": "https://files.pythonhosted.org/packages/fc/91/a00997b51f7abcc9e0b76fb2bdcac64410492e49c29af099a11907636a4a/djurl-0.2.0.tar.gz" } ] }