Philosophy

Key principles

  1. Validation logic is separate from the main logic.
  2. Reusable logic for many views.
  3. Reusable input and output data formats.
  4. More clean views.

Dataflow

  1. Decorators. Feel free to use any side Django decorators like csrf_exempt.
  2. Parser. Parse request body.
  3. PreValidator. Validate and clear request.
  4. PreRenderer. Render and return PreValidation errors response.
  5. Controller. Main logic: do some things.
  6. PostValidator. Validate and clear response.
  7. PostRenderer. Render and return PostValidation errors response.
  8. Renderer. Render successful response.

Scheme

Required only controller and renderer.

Solved problems

  1. Mixins chaos and wrong usage. Mixins is good but dangerous conception. Use it carefully.
  2. You can decorate Django view in so many places: urls, view, dispatch method, get/post method, form_valid method etc. DjBurger has special place for all decorators.
  3. Validation and main logic mixing. In bad code you can validate and apply some data in one loop, and if you found and return validation error then operation will be applied partially. Example:
for user in users:
    if user.is_anonymous():
        raise ValueError("Can't send SMS to anonymous user!")
    send_sms(user)

This is bad code! We will send some SMS before error raising. DjBurger force input validation only before main logic.

  1. Big and implicit views. This code is unsupported and non-expandable. DjBurger split view by steps.
  2. Logic duplication in views require more time to made changes and and increase probability of mistake. With DjBurger you can use one controller into many views.