Skip to main content

django-redis-views

https://badge.fury.io/py/django-redis-views.png https://travis-ci.org/kevinlondon/django-redis-views.png?branch=master

Simple Redis-based generic views for serving your Django-backed Ember CLI apps.

Documentation

The full documentation is at https://django-redis-views.readthedocs.org.

Features

Background

Ember CLI and other single-page javascript apps can be challenging to deploy.

Luke Melia presented a talk called Lightning Fast Deployment of Your Rails-backed JavaScript app, which eventually led to the creation of ember-cli-deploy.

This project acts as the glue between ember-cli-deploy and Django by providing generic views to serve Redis-backed index pages for single page javascript applications.

Quickstart

Let’s assume we already have an Ember CLI app that we’re ready to deploy. We’re using the ember-deploy-redis adapter and we ran ember deploy to push the index.html file into Redis. In this case, we’ll pretend that the Ember CLI project’s name is ember-cli-my-great-app.

First, install django-redis-views:

pip install django-redis-views

In your Django settings file, set the Redis url. For example, you may want to access Redis on the localhost running on the default port. In which case, you would add something like this to the your settings.py file:

REDIS_URL = 'redis://localhost:6379/0'

Then, to use it in your Django project, first add a new view to a views.py file:

from redis_views import RedisView


class EmberAppIndex(RedisView):
    app_name = 'ember-cli-my-great-app'

And then set it a route for it in your urls.py file:

from django.conf.urls import patterns
from myapp.views import EmberAppIndex


urlpatterns = patterns('',
    url(r'^$', EmberAppIndex.as_view()),
)

At this point, you should be able to go to your root url and see your index page!

TODO: Walk through a full example project.

Injecting Context to your Template

If you want to use Django’s template engine to replace values in your Ember index file, you can do that by injecting the context. Let’s pretend that we have this very simple Ember index page:

<p>Hello {{ name }}!</p>

In order to inject {{ name }} from Django into the Ember index page, you’ll want to add to the context. This package is built upon the generic views in Django, so we inject context the same way that they do. In your views.py file (using the same conventions as above):

from redis_views import RedisView

class EmberAppIndex(RedisView):

    . . .

    def get_context_data(self, **kwargs):
        # Call the base implementation first to get a context
        context = super(EmberAppIndex, self).get_context_data(**kwargs)
        # Add in the name value (you could also use a dynamic value from a database object)
        context['name'] = 'Joe'
        return context

Then, in the template, it will fill in the value with your supplied value. As mentioned in the comment, you can inject pretty much anything that could normally be handled by Django templates, such as a CSRF token.

Running the Tests

To run the tests, please do the following in your terminal:

# Install the testing requirements
pip install -r requirements-test.txt

# Run the tests
py.test

Cookiecutter Tools Used in Making This Package

  • cookiecutter

  • cookiecutter-djangopackage

History

0.2.2 (2015-10-20)

  • Fixed bug with setting the socket timeout without a kwarg.

0.2.1 (2015-10-20)

  • Added a socket timeout and server pinging when connecting to the server to raise a ConnectionError if there are any connection issues.

  • Added error logging of missing template keys.

0.2.0 (2015-09-21)

  • Changed the GET parameter value from version to index_key to match the convention established by ember-cli-deploy.

0.1.0 (2015-08-22)

  • First release on PyPI.

Metadata

Release files for django-redis-views 0.2.2

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-redis-views 0.2.2
File Size Uploaded Provenance Actions
django-redis-views-0.2.2.tar.gz 7.4 kB Without provenance Details for django-redis-views-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-redis-views 0.2.2
File Interpreter ABI Platform Actions
django_redis_views-0.2.2-py2.py3-none-any.whl Python 3, Python 2 none any Details for django_redis_views-0.2.2-py2.py3-none-any.whl

Total release size: 15.8 kB

Release files / django-redis-views-0.2.2.tar.gz

Download URL django-redis-views-0.2.2.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
31e2d93fb526bce89dcf47a5d92ef8b9bed0f9e61e41f13f5e60e4f5c47fa07e
BLAKE2b-256 checksum
How to use checksums
b6e7f3ac0c9b09a61eae0de87df8ca0f6f069d12a9f51039aa7269bac8d5033c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_redis_views-0.2.2-py2.py3-none-any.whl

Download URL django_redis_views-0.2.2-py2.py3-none-any.whl
Size 8.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
613a8fb2bef7cdc022eef6c86fe9474b295615a74ebf5de7664b8389e2e7d8b3
BLAKE2b-256 checksum
How to use checksums
4b5090a64d83326ffa1b6feabb959c51f8a3b713cf65df6fc7dc30d893853f66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-redis-views 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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