Skip to main content

Django Dict Response

Project description

Overview

Write views.py simply.

Usage

Before:

from django.shortcuts import redirect, render

def view(request):
    ...
    if request.method == 'POST':
        ...
        return redirect(url)
    response = render(request, template_name, dict(obj=obj, title=title), status=200)
    response['Age'] = 120
    return response

After:

def view(request):
    ...
    if request.method == 'POST':
        ...
        return {'redirect_to': [url]}
    return dict(Age=120, obj=obj, template_name=template_name, title=title, status=200)

Installation

  1. Install using pip:

    pip install -U django-dict-response

  2. Add to last of MIDDLEWARE_CLASSES in your settings.py:

    'django_dict_response.middlewares.DictResponseMiddleware',

Dependencies

Django >= 1.7

Configuration

  • REDIRECT_KEY

    The setting is used when redirect
    default: 'redirect_to'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-dict-response, version 0.0.8
Filename, size File type Python version Upload date Hashes
Filename, size django-dict-response-0.0.8.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page