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.
pip install django-annoyingVerified import paths — ran on the pinned version, not inferred.
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`.
Migrate to Django's built-in signal connection methods (e.g., `django.db.models.signals.post_save.connect`).
Remove the `autostrip` decorator and rely on Django's default form field behavior or explicitly set `strip=True` on `CharField` and `TextField`.
Always provide a callable (e.g., `default=dict` or `default=list`) for mutable default values in model fields to ensure each new instance gets its own independent default object.
Ensure your Django project is running Django 1.11 or a more recent, supported version. Check the `django-annoying` release notes for specific compatibility details for your `django-annoying` version.
Provide a callable for the default, like `JSONField(default=dict)`. This ensures a fresh dictionary is created for each new model instance.
Ensure `Http404` is raised before the decorator attempts to process a return value, typically at the beginning of the view or within a `get_object_or_404` call. Alternatively, if a non-dictionary (like an `HttpResponseRedirect` or a direct `HttpResponseNotFound`) is returned, `@render_to` will pass it through without processing.