• 
      

    Improve the editing experience for JSONFields.

    Review Request #9405 — Created Nov. 27, 2017 and submitted

    Information

    Djblets
    release-1.0.x
    0172908...

    Reviewers

    JSONFormField (through JSONField) had a pretty underwhelming editing
    experience when used in forms. The text field would just contain a big
    blob of serialized JSON content, which was pretty hard to read and
    modify.

    Now, the text field shows a pretty-printed representation of the JSON
    data, with all keys sorted to make it easier to find the key you want.
    When saved, the resulting data is once again condensed, but with the
    keys remaining sorted in the database.

    In order to do this, the old encoder argument for these classes has
    been deprecated, with new encoder_cls and encoder_kwargs replacing
    them. This allows the classes to decide when the encoder is constructed
    and to provide additional arguments to control the behavior. Any
    consumers providing a custom encoder today will not see the new editing
    behavior, falling back on the legacy behavior instead.

    Manually tested loading a JSON structure and editing it in the Admin UI.
    Saw that the data was nicely indented and sorted. Saved it and saw that
    the data was condensed in the database, but still sorted.

    Unit tests pass.

    Description From Last Updated

    Can we list encoder first to match the JSONField constructor? Or change that one to match this?

    daviddavid

    We don't actually emit a warning in this method.

    daviddavid

    This should probably return self.encoder if it exists.

    daviddavid

    Too many blank lines.

    daviddavid
    david
    1. 
        
    2. djblets/db/fields.py (Diff revision 1)
       
       
      Show all issues

      Can we list encoder first to match the JSONField constructor? Or change that one to match this?

    3. djblets/db/fields.py (Diff revision 1)
       
       
       
      Show all issues

      We don't actually emit a warning in this method.

    4. djblets/db/fields.py (Diff revision 1)
       
       
      Show all issues

      This should probably return self.encoder if it exists.

      1. No need. The property will be overridden in that case.

    5. djblets/db/fields.py (Diff revision 1)
       
       
       
      Show all issues

      Too many blank lines.

    6. 
        
    chipx86
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-1.0.x (a8fc9f9)