{ "info": { "author": "Mishbah Razzaque", "author_email": "mishbahx@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3" ], "description": "=============================\ndjango-responsive2\n=============================\n\n.. image:: http://img.shields.io/travis/mishbahr/django-responsive2.svg?style=flat-square\n :target: https://travis-ci.org/mishbahr/django-responsive2/\n\n.. image:: http://img.shields.io/pypi/v/django-responsive2.svg?style=flat-square\n :target: https://pypi.python.org/pypi/django-responsive2/\n :alt: Latest Version\n\n.. image:: http://img.shields.io/pypi/dm/django-responsive2.svg?style=flat-square\n :target: https://pypi.python.org/pypi/django-responsive2/\n :alt: Downloads\n\n.. image:: http://img.shields.io/pypi/l/django-responsive2.svg?style=flat-square\n :target: https://pypi.python.org/pypi/django-responsive2/\n :alt: License\n\n.. image:: http://img.shields.io/coveralls/mishbahr/django-responsive2.svg?style=flat-square\n :target: https://coveralls.io/r/mishbahr/django-responsive2?branch=master\n\n\ndjango-responsive2 is an experimental Django app that gives web designers tools for building\nresponsive websites. It can dynamically swap content based on breakpoints.\n\nWhy would you use django-responsive2?\n-------------------------------------\n\nThis project was inspired by Twitter Bootstrap's `Responsive Utilities `_. Bootstrap provides some handful helper classes, for faster mobile-friendly development. These\ncan be used for showing and hiding content by device via media query combined with large, small,\nand medium devices.\n\nSimilarly ``django-responsive2`` can be used to render different content based on device screen sizes and pixel ratios.\nHowever, while it is very useful to show/hide content using css display property, Bootstrap Responsive Utilities does not actually prevent the content from being loaded on to the page. It is best explained through examples.\n\n\n**Sample example template using django-responsive2**::\n\n
\n
\n {% if device.is_xsmall or device.is_small %}\n
\n {# Rendered for x-small/small screen devices #}\n \"Descriptive\n
\n {% elif device.is_medium %}\n
\n {# Rendered for medium screen devices #}\n \"Descriptive\n
\n {% else %}\n
\n {# Rendered for large/xlarge screen devices #}\n \"Descriptive\n
\n {% endif %}\n
\n
\n\nIn this very simple example, using the Bootstrap Responsive Utilities, all 3 images would have been loaded on to the page, wasting precious bandwidth, together with increase in page load time.\n\nIn comparison, using ``django-responsive2``, only ``col-sm`` will be rendered for small screen devices (e.g. an iPhone), ``col-m`` will be displayed for medium screen devices (e.g. an iPad) and lastly ``col-lg`` will be visible for large screen devices or any devices that do not match the rules for small/medium devices.\n\n\nUsing django-responsive2 in your views\n--------------------------------------\n\nYou can also use the ``django-responsive2`` in your Django views to do particular things based on the matched media queries for the visitors device.\n\nThe ``ResponsiveMiddleware`` middleware sets the ``device`` attribute on every request object, so you can use ``request.device`` to get the device information for your visitors::\n\n\tMIDDLEWARE_CLASSES=(\n\t ...\n\t 'responsive.middleware.ResponsiveMiddleware'\n\t ...\n\t)\n\nHere\u2019s an (verbose) example of what the a view could look like, ``request.device.matched`` returns a list of matched media queries for the visitors device.\n\ne.g. ``['small', 'retina']`` ::\n\n\n\tdef home(request):\n\n if 'retina' in request.device.matched:\n thumbnail_high_resolution = True\n else:\n thumbnail_high_resolution = False\n\n if request.device.is_small:\n hide_ads = True\n else:\n hide_ads = False\n\n ...\n context = {\n 'thumbnail_high_resolution': thumbnail_high_resolution,\n 'hide_ads': hide_ads\n }\n\n ...\n\nQuickstart\n----------\n\n1. Install django-responsive2::\n\n pip install django-responsive2\n\n2. Add ``responsive`` to ``INSTALLED_APPS``::\n\n INSTALLED_APPS = (\n ...\n 'responsive',\n ...\n )\n\n3. Add ``django.core.context_processors.request`` and ``responsive.context_processors.device`` to your ``TEMPLATE_CONTEXT_PROCESSORS``::\n\n TEMPLATE_CONTEXT_PROCESSORS = (\n ...\n 'django.core.context_processors.request',\n 'responsive.context_processors.device',\n ...\n )\n\n4. Add the ``ResponsiveMiddleware`` to MIDDLEWARE_CLASSES::\n\n MIDDLEWARE_CLASSES = (\n ...\n 'responsive.middleware.ResponsiveMiddleware',\n ...\n )\n\n\n\nConfiguration\n-------------\n``django-responsive2`` lets you to define the breakpoints at which your layout will change,\nadapting to different screen sizes. Here's the default breakpoints::\n\n RESPONSIVE_MEDIA_QUERIES = {\n 'small': {\n 'verbose_name': _('Small screens'),\n 'min_width': None,\n 'max_width': 640,\n },\n 'medium': {\n 'verbose_name': _('Medium screens'),\n 'min_width': 641,\n 'max_width': 1024,\n },\n 'large': {\n 'verbose_name': _('Large screens'),\n 'min_width': 1025,\n 'max_width': 1440,\n },\n 'xlarge': {\n 'verbose_name': _('XLarge screens'),\n 'min_width': 1441,\n 'max_width': 1920,\n },\n 'xxlarge': {\n 'verbose_name': _('XXLarge screens'),\n 'min_width': 1921,\n 'max_width': None,\n }\n }\n\n** Borrowed from ZURB Foundation framework, see http://foundation.zurb.com/docs/media-queries.html\n\nWhile there are several different items we can query on, the ones used for django-responsive2\nare min-width, max-width, min-height and max-height.\n\n* min_width \u2014 Rules applied for any device width over the value defined in the config.\n* max_width \u2014 Rules applied for any device width under the value defined in the config.\n* min_height \u2014 Rules applied for any device height over the value defined in the config.\n* max_height \u2014 Rules applied for any device height under the value defined in the config.\n* pixel_ratio \u2014 Rules applied for any device with devicePixelRatio defined in the config.\n\nYou can override the default media queries by defining own in your ``RESPONSIVE_MEDIA_QUERIES``\nin your ``settings.py``. For example::\n\n RESPONSIVE_MEDIA_QUERIES = {\n 'iphone': {\n 'verbose_name': _('iPhone Retina'),\n 'min_width': 320, # mobile first queries\n 'pixel_ratio': 2\n },\n ...\n }\n\nFor every media queries, the ``device`` object will have a ``is_FOO`` attribute, where FOO\nis the name of the media query. This attribute returns ``True/False``.\n\nContinuing with the example ``RESPONSIVE_MEDIA_QUERIES`` settings above, here\u2019s a simple corresponding template::\n\n
\n
\n {% if device.is_iphone %}\n {# this snippet will only be rendered for retina devices with minimum device width 320 #}\n \n {% endif %}\n
\n
\n\nDocumentation\n-------------\n\nThe full documentation is at https://django-responsive2.readthedocs.org.\n\nCredits\n--------\n\nThis app started as a clone of ``django-responsive`` with some minor modifications to fit my own project requirements. So a big thank you to `@mlavin `_ for his hard work.\n\nShout out to `@jezdez `_ for the awesome ``django-appconf`` \u2014 used by this project to handle default configurations.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mishbahr/django-responsive2", "keywords": "django-responsive2,responsive", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-responsive2", "package_url": "https://pypi.org/project/django-responsive2/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-responsive2/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/mishbahr/django-responsive2" }, "release_url": "https://pypi.org/project/django-responsive2/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Utilities for building responsive websites in Django", "version": "0.1.3" }, "last_serial": 1835262, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e2661f0868b0ea480e21eedfd04ccf19", "sha256": "09e578e32d26ca314687daf10575844163d16e5e8f772f68d2977fc1c5ac3c6c" }, "downloads": -1, "filename": "django-responsive2-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e2661f0868b0ea480e21eedfd04ccf19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9111, "upload_time": "2014-10-04T23:26:40", "url": "https://files.pythonhosted.org/packages/01/5f/234cc9d212e1bc59f9a63eac72463c6a5f609bfdef584a92e77f980fe45d/django-responsive2-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4fbc9cce0d11fcfcc30cdb09937c5546", "sha256": "18d3ee578ab9c74b5918a42523d6b814af7c802b36eaf790fbe87bd49e15f35b" }, "downloads": -1, "filename": "django-responsive2-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4fbc9cce0d11fcfcc30cdb09937c5546", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9735, "upload_time": "2014-10-07T23:43:01", "url": "https://files.pythonhosted.org/packages/9f/69/0c3816068a33486a40ad506acfefade1d3bc8c81574384843feafc88650d/django-responsive2-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "dc5db4fa5b307e7ec12d31b128736e93", "sha256": "927eef4e77bab48f201d3e87d786197412b9b2ef2dc7afda7f090737becfbb38" }, "downloads": -1, "filename": "django-responsive2-0.1.2.tar.gz", "has_sig": false, "md5_digest": "dc5db4fa5b307e7ec12d31b128736e93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9647, "upload_time": "2015-10-16T15:05:53", "url": "https://files.pythonhosted.org/packages/9d/ee/d3467299aabba4b80ca6f984640a29b2deeaa271d1202d9293b959aadf19/django-responsive2-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5d5ab60324d26b2d58c0f685ea1b986d", "sha256": "76792846c38691e398259b3341909534eb781217c5e35ead2f106412748d1365" }, "downloads": -1, "filename": "django-responsive2-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5d5ab60324d26b2d58c0f685ea1b986d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9656, "upload_time": "2015-11-26T17:00:35", "url": "https://files.pythonhosted.org/packages/bc/c4/3eda7d6082abedb983465a46b07cd3d7ebce2433e648c604858ab9955ca6/django-responsive2-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5d5ab60324d26b2d58c0f685ea1b986d", "sha256": "76792846c38691e398259b3341909534eb781217c5e35ead2f106412748d1365" }, "downloads": -1, "filename": "django-responsive2-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5d5ab60324d26b2d58c0f685ea1b986d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9656, "upload_time": "2015-11-26T17:00:35", "url": "https://files.pythonhosted.org/packages/bc/c4/3eda7d6082abedb983465a46b07cd3d7ebce2433e648c604858ab9955ca6/django-responsive2-0.1.3.tar.gz" } ] }