Skip to main content

Django-Responsive

https://travis-ci.org/mlavin/django-responsive.svg?branch=master

django-responsive a utility application for building responsive websites in Django. This tool is meant to complement the use of CSS media queries and help solve problems with fixed width elements such as advertisements or embedded video.

This project does not match devices based on user agent strings and instead uses a small piece of javascript to make the device window size available on the server. Once enabled you can access a device_info dictionary in your templates:

{'width': 320, 'type': 'phone', 'height': 480}

Now you and conditionally render content based on the device size or type.

Installation

django-responsive requires Python 2.6 or 2.7 and django>=1.3. There is experimental support for Python 3.2 if using Django >= 1.5. It is easiest to install django-responsive from PyPi using pip:

pip install django-responsive

Configuration

To enable django-responsive you will need to update your MIDDLEWARE_CLASSES and TEMPLATE_CONTEXT_PROCESSORS settings.:

MIDDLEWARE_CLASSES = (
    # Other middleware classes go here
    'responsive.middleware.DeviceInfoMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    # Other context processors included here
    'responsive.context_processors.device_info',
)

Note that TEMPLATE_CONTEXT_PROCESSORS is not included in the default settings and you should be careful to not lose the defaults when adding this additional context processor.

There is an optional setting RESPONSIVE_BREAKPOINTS which is used to determine the type included in the device_info dictionary. The default breakpoints are:

# Name, Max Width (inclusive)
DEFAULT_BREAKPOINTS = {
    'phone': 480,
    'tablet': 767,
    'desktop': None,
}

To overwrite the default breakpoints, include a RESPONSIVE_BREAKPOINTS dictionary in the project’s settings.py file:

# Name, Max Width (inclusive)
RESPONSIVE_BREAKPOINTS = {
    'phone': 480,
    'tablet': 767,
    'desktop': None,
}

License

django-responsive is released under the BSD License. See the LICENSE file for more details.

Contributing

If you think you’ve found a bug or are interested in contributing to this project check out django-responsive on Github.

Running the Tests

You can run the tests with via:

python runtests.py

If you see any test failures please report them to the Github issue tracker.

Metadata

Release files for django-responsive 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-responsive 0.3.0
File Size Uploaded
django-responsive-0.3.0.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-responsive 0.3.0
File Interpreter ABI Platform
django_responsive-0.3.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 18.9 kB

Release files / django-responsive-0.3.0.tar.gz

Download URL django-responsive-0.3.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f6e2b2b7661914b4dc07ef13f372ee36fe2eb1dcaf5888f4f34031395b84f12d
BLAKE2b-256 checksum
How to use checksums
1a5fc745fbe71f3fda3ba96a74bad9edd49f98008579e8c7c927fa8d0cc220e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_responsive-0.3.0-py2.py3-none-any.whl

Download URL django_responsive-0.3.0-py2.py3-none-any.whl
Size 11.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
332cf5408f958cf5f411a95dbb68a29ceb3932c21e35ca944b34bed098008abf
BLAKE2b-256 checksum
How to use checksums
93a87462034b8c3671862ab0decc673528e6abd05fba168f31abffb54b9fbb81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page