This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django-urlconverter: Django automatic view parameters conversion

The django-urlconverter package provides an easy way to convert view arguments from simple types to complex ones, like models, or just do some processing using robust syntax. Most interesting application of the package is to convert view arguments which are object ids (from database via ORM) to the instances of those objects (Models).

Installation

pip install django-urlconverter

Usage

models.py:

from django.db import models


class FooBar(models.Model):
    """Foo Bar model."""
    title = models.CharField(max_length=100)

converters.py:

from .models import FooBar


class Foo(object):
    """Foo converter. Convert an object id to FooBar instance."""
    def __init__(self, **kwargs):
        self.kwargs = kwargs

    def __call__(self, value, request, *args, **kwargs):
        return FooBar.objects.get(pk=value)

settings.py:

URL_CONVERTERS = {
    'Foo': 'converters.Foo',  # Converts to 'FooBar instance'
}

urls.py:

from django.conf.urls.defaults import patterns
from django_urlconverter import converted_arguments_url

urlpatterns = patterns('views',
    converted_arguments_url(r'^foos/<Foo:foo2>/', 'bar'),
)

views.py:

def bar(request, foo2):
    """View function which gets a converted foo2.
    the foo2 will be a converted parameter, which is the result of Foo converter
    """
    return foo2.title

Contact

If you have questions, bug reports, suggestions, etc. please create an issue on the GitHub project page.

License

This software is licensed under the MIT license

See https://github.com/paylogic/django-urlconverter/blob/master/LICENSE.txt

© 2013 Paylogic International.

Changelog

1.0.0

  • Initial public release
Release History

Release History

1.0.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-urlconverter-1.0.0.tar.gz (5.5 kB) Copy SHA256 Checksum SHA256 Source Dec 3, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting