Django Annoying

0.10.8 · active · verified Thu Apr 16

django-annoying is a Django application designed to simplify common, repetitive tasks and eliminate boilerplate code in Django projects. It provides a collection of useful decorators for views (like `@render_to`, `@ajax_request`, `@autostrip`), utility functions (`get_object_or_None`, `get_config`), and custom model fields (`JSONField`, `AutoOneToOneField`). The library is currently at version 0.10.8, with recent updates adding support for newer Django versions and deprecating features now built into Django itself. It maintains an active release cadence, typically addressing compatibility and minor feature enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the `render_to` decorator for simplifying view returns and the `JSONField` for storing JSON data in models. Remember to add 'annoying' to your `INSTALLED_APPS` in `settings.py`.

from django.shortcuts import render
from django.http import HttpResponse
from annoying.decorators import render_to

# views.py example

@render_to('my_app/my_template.html')
def my_view(request):
    context = {'message': 'Hello from django-annoying!'}
    return context # The decorator handles rendering this dict to a template

# models.py example
from django.db import models
from annoying.fields import JSONField

class MyModel(models.Model):
    data = JSONField(default=dict) # Use a callable for mutable defaults

    def __str__(self):
        return f"MyModel object with data: {self.data}"

view raw JSON →