Upgrade to Pro — share decks privately, control downloads, hide ads and more …

REST framework: Under the Hood

Tom Christie
November 15, 2014

REST framework: Under the Hood

Tom Christie

November 15, 2014
Tweet

Other Decks in Technology

Transcript

  1. “Fat models, thin views.” ↓ “Never write to a model

    field or call .save() directly. Always use model methods and manager methods for state changing operations.” Saturday, 15 November 14
  2. We want explicit validation behavior, but we’d still like the

    ModelSerializer shortcut. Saturday, 15 November 14
  3. We can use the ModelSerializer shortcut, but our validation behavior

    is made visible & explicit. • unique_together • field validation Saturday, 15 November 14
  4. Consequences of dropping ‘Model.full_clean()’ • All field validation handled. •

    All uniqueness validation handled. • `Model.clean()` → `Serializer.validate()` Saturday, 15 November 14
  5. Once we’ve got all that it’s easy enough to write

    a renderer class that uses templated HTML generation... Saturday, 15 November 14
  6. The REST framework 3.0 big picture. • Easier to override

    save behavior. • More explicit validation. • Better model encapsulation. • Less complex internal implementation. • Supports both Form and API output. • Template based form rendering. • Nested forms and lists of forms. • API compatibility with CBVs. • BaseSerializer for custom cases. Saturday, 15 November 14
  7. RSS • Machine readable hypermedia format. • Big win due

    to shared tooling. • Domain specific. Saturday, 15 November 14
  8. HTML • Closest we’ve come to a universal platform. •

    Document centric, not data centric. • Not intended for programmatic interaction. Saturday, 15 November 14
  9. Document Object Model Data Object Model • An abstract object

    interface. • Agnostic to UI environment. • Programmable. • Implied UI model. • Browser environment only. • Not programmable. ~ Saturday, 15 November 14
  10. • Generic client libraries. • In-browser tools. • Functional testing

    of our applications. • UI binding libraries. • Transparently upgrade encoding or transport layers. The big wins. Saturday, 15 November 14
  11. It’s time to start addressing the fundamental issues of system

    communication. ~ How do we design abstract object interfaces, and describe the actions and transforms they expose. Saturday, 15 November 14