Login

Snippets by axil

Snippet List

Skip only specified spaces

Similar to `{% spaceless %}`, but only removes spaces followed by a special marker (`&nosp;`). Helps keeping proper indentation: {% skipspaces %} Lots of coffee {% if from_brazil %} from Brazil {% else %} from Columbia {% endif %} {% if tea %}&nosp;, some tea{% endif %} and a cake. {% endskipspaces %} Otherwise you'd have to write it in one looong line or get used to living with spaces before commas :) NB the marker itself is stripped from rendered html as well.

  • spaceless
  • whitespace
  • skip
  • spaces
Read More

Coalesce for F()

Updating fields that allow for NULLs must take care about those NULLs. Use case: `Message.objects.filter(id=1).update(price=CF('price', 0) + 7)` `Message.objects.filter(id=1).update(status=CF('status') // 's')` Works for postgres. Supposedly works for mysql. Didn't test with other backends.

  • coalesce
Read More

axil has posted 2 snippets.