{ "info": { "author": "R. Moelker", "author_email": "", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP" ], "description": "django-full-url\n===================\n\nGetting specific parts of an URL for the current page in Django can be quite tedious. This small package makes it easy to get parts of the URL by providing python helpers and a context processor. All the information is gathered from a RequestContext object, no error prone 'Site' config needed!\n\nSome of the URL parts you can extract:\n\n* domain\n* http or https\n* port\n* path\n* query (get parameters)\n\nThere are some situations where you might want to get specific URL parts:\n\n* Add the domain name for including images on your domain in an email.\n* Get the full URL (protocol, domain, path and query) for sharing the page on social networks.\n* Get a link to same page using 'http' or 'https'.\n\n## Installation\n\nEither install directly:\n\n`pip install -e git+https://github.com/RRMoelker/django-full-url.git#egg=django-full-url`\n\nOr add the following line to your requirements file:\n\n`-e git+https://github.com/RRMoelker/django-full-url.git#egg=django_full_url`\n\n\n## Usage\n\nThere are currently two ways to get the URL information. One method uses a context processor to make the different URL parts data available in all [templates](#context-processor). The second method provides helpers to get the information directly from within a view or another place where you have access to a RequestObject in the [python code](#python-code). For available parameters see [RequestGrabber](#grabber)\n\n### Context processor\n\nYou can add a context processor that will add the variable `url_parts` to all templates.\nThe processor can be added anywhere in the `TEMPLATE_CONTEXT_PROCESSORS` list:\n\n```\nTEMPLATE_CONTEXT_PROCESSORS = (\n # ...\n 'full_url.context_processors.UrlParts',\n # ...\n)\n```\n\nThe `url_parts` variable is a [RequestGrabber](#grabber) object. To actually insert part of the url into the template you can do:\n```\n...\n{{url_parts.domain}}\n...\n```\n\n\n### Python code\n\nTo get URL information in python use the [RequestGrabber](#grabber).\n```\nfrom full_url.grabber import RequestGrabber\n```\n\nCreate an instance of the RequestGrabber object using:\n\n```\nurl_parts = RequestGrabber(request)\n```\n\nTo get a part use: `url_parts.domain()`. See [RequestGrabber](#grabber) for available URL parts.\n\n\n## RequestGrabber\n\nSay we are looking at the following view: `http://localhost:8000/news/2014/?sort=ascending#item2`\n\nThe RequestGrabber has the following functions available:\n\n* protocol: http://\n* domain: localhost:8000\n* port: 8000\n* path: /news/2014/\n* query: sort=ascending\n* full_url: /news/2014/?sort=ascending\n* absolute_uri: http://localhost:8000/news/2014/?sort=ascending\n\nNote that we cannot get the fragment part of the URL (#item2).\nDuring normal operations a browser should never send this information so no functionality to get it is provided at this time.\n\n## Requirements\nDjango\n(Tested with Django 1.6 and 1.7. Please let me know if it works in other versions setups)\n\n## Uninstall\nNothing fancy here:\n\n```\npip uninstall django-full-url\n```\n\nEncountered a bug or missing a feature? Please create a ticket to help improve this tool!", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-full-url", "package_url": "https://pypi.org/project/django-full-url/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-full-url/", "project_urls": null, "release_url": "https://pypi.org/project/django-full-url/0.1/", "requires_dist": null, "requires_python": "", "summary": "Small tool for easily getting parts or full URL in Django templates and views.", "version": "0.1" }, "last_serial": 2677956, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7e6f8ce17927bcd9f1e9a7491880d89d", "sha256": "1cc96e0bba578f4cfcc555577d4ed3cce55fed06260cfccf1120597ddc67e222" }, "downloads": -1, "filename": "django-full-url-0.1.tar.gz", "has_sig": false, "md5_digest": "7e6f8ce17927bcd9f1e9a7491880d89d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4217, "upload_time": "2017-03-02T11:38:40", "url": "https://files.pythonhosted.org/packages/d8/9a/8d26fa5b96fcd0ddfee34098c8915b4eb6234e2754a960094d2161fb7143/django-full-url-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7e6f8ce17927bcd9f1e9a7491880d89d", "sha256": "1cc96e0bba578f4cfcc555577d4ed3cce55fed06260cfccf1120597ddc67e222" }, "downloads": -1, "filename": "django-full-url-0.1.tar.gz", "has_sig": false, "md5_digest": "7e6f8ce17927bcd9f1e9a7491880d89d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4217, "upload_time": "2017-03-02T11:38:40", "url": "https://files.pythonhosted.org/packages/d8/9a/8d26fa5b96fcd0ddfee34098c8915b4eb6234e2754a960094d2161fb7143/django-full-url-0.1.tar.gz" } ] }