Giter Site home page Giter Site logo

dakotahawkins / djangorestframework-camel-case Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vbabiy/djangorestframework-camel-case

0.0 2.0 0.0 41 KB

Camel case JSON support for Django REST framework.

License: Other

Makefile 9.36% Python 90.64%

djangorestframework-camel-case's Introduction

Django REST Framework JSON CamelCase

image

image

Camel case JSON support for Django REST framework.

Installation

At the command line:

$ pip install djangorestframework-camel-case

Add the render and parser to your django settings file.

# ...
REST_FRAMEWORK = {

    'DEFAULT_RENDERER_CLASSES': (
        'djangorestframework_camel_case.render.CamelCaseJSONRenderer',
        # Any other renders
    ),

    'DEFAULT_PARSER_CLASSES': (
        'djangorestframework_camel_case.parser.CamelCaseJSONParser',
        # Any other parsers
    ),
}
# ...

Swapping Renderer

By default the package uses rest_framework.renderers.JSONRenderer. If you want to use another renderer (the only possible alternative is rest_framework.renderers.UnicodeJSONRenderer, only available in DRF < 3.0), you must specify it in your django settings file.

# ...
JSON_CAMEL_CASE = {
    'RENDERER_CLASS': 'rest_framework.renderers.UnicodeJSONRenderer'
}
# ...

Underscoreize Options

As raised in krasa/StringManipulation#8 (comment) there are two conventions of snake case.

# Case 1 (Package default)
v2Counter -> v_2_counter
fooBar2 -> foo_bar_2

# Case 2
v2Counter -> v2_counter
fooBar2 -> foo_bar2

By default, the package uses the first case. To use the second case, specify it in your django settings file.

REST_FRAMEWORK = {
    # ...
    'JSON_UNDERSCOREIZE': {
        'no_underscore_before_number': True,
    },
    # ...
}

Running Tests

To run the current test suite, execute the following from the root of he project:

$ python -m unittest discover

License

  • Free software: BSD license

djangorestframework-camel-case's People

Contributors

adam-rescale avatar alaminopu avatar dbrgn avatar dgilge avatar dickenwong avatar jacobg avatar jakob-o avatar magul avatar ondrowan avatar romanosipenko avatar timeu avatar vbabiy avatar yatoff avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.