Add support for serializing django Models

Review Request #7821 — Created Dec. 22, 2015 and submitted

Information

Djblets
release-0.9.x

Reviewers

Django Models with a to_json method can now be serialized with the
DjbletsJSONEncoder. The to_json method should return a
JSON-serializable object (such a dict, list, or string) that will then
be serialized by the encoder. Unit tests have been added to test this
behaviour.

  • Ran unit tests.
Description From Last Updated

'Model' imported but unused

reviewbotreviewbot

Can we also add and callable(obj.to_json)?

daviddavid

Docstring?

daviddavid

Leftover debug output?

daviddavid

This change is no longer necessary.

daviddavid

local variable 'e' is assigned to but never used

reviewbotreviewbot
brennie
david
  1. 
      
  2. djblets/util/serializers.py (Diff revision 2)
     
     
    Show all issues

    Can we also add and callable(obj.to_json)?

  3. djblets/util/tests.py (Diff revision 2)
     
     
    Show all issues

    Docstring?

  4. djblets/webapi/encoders.py (Diff revision 2)
     
     
     
    Show all issues

    Leftover debug output?

  5. 
      
brennie
david
  1. 
      
  2. djblets/webapi/encoders.py (Diff revision 3)
     
     
    Show all issues

    This change is no longer necessary.

  3. 
      
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
        djblets/webapi/encoders.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
        djblets/webapi/encoders.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
        djblets/webapi/encoders.py
    
    
  2. djblets/webapi/encoders.py (Diff revision 1)
     
     
    Show all issues
     'Model' imported but unused
    
  3. djblets/webapi/encoders.py (Diff revision 3)
     
     
    Show all issues
     local variable 'e' is assigned to but never used
    
  4. 
      
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
        djblets/webapi/encoders.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
        djblets/webapi/encoders.py
    
    
  2. 
      
brennie
brennie
brennie
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to release-0.9.x (aa76e12)
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/util/tests.py
        djblets/util/serializers.py
    
    
  2.