{"id":7163,"library":"django-annoying","title":"Django Annoying","description":"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.","status":"active","version":"0.10.8","language":"en","source_language":"en","source_url":"https://github.com/skorokithakis/django-annoying","tags":["django","utilities","decorators","fields","productivity","boilerplate"],"install":[{"cmd":"pip install django-annoying","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core functionality relies on the Django framework; requires Django 1.11 or later.","package":"Django","optional":false}],"imports":[{"symbol":"render_to","correct":"from annoying.decorators import render_to"},{"symbol":"ajax_request","correct":"from annoying.decorators import ajax_request"},{"symbol":"JSONField","correct":"from annoying.fields import JSONField"},{"symbol":"AutoOneToOneField","correct":"from annoying.fields import AutoOneToOneField"},{"symbol":"get_object_or_None","correct":"from annoying.functions import get_object_or_None"},{"note":"The `annoying.decorators.signals` is deprecated. Modern Django has native signal handling, or it may be confused with standard Django signals.","wrong":"from django.db.models import signals","symbol":"signals","correct":"from annoying.decorators import signals"},{"note":"The `annoying.decorators.autostrip` is deprecated. Modern Django forms handle stripping natively.","wrong":"from django import forms","symbol":"autostrip","correct":"from annoying.decorators import autostrip"}],"quickstart":{"code":"from django.shortcuts import render\nfrom django.http import HttpResponse\nfrom annoying.decorators import render_to\n\n# views.py example\n\n@render_to('my_app/my_template.html')\ndef my_view(request):\n    context = {'message': 'Hello from django-annoying!'}\n    return context # The decorator handles rendering this dict to a template\n\n# models.py example\nfrom django.db import models\nfrom annoying.fields import JSONField\n\nclass MyModel(models.Model):\n    data = JSONField(default=dict) # Use a callable for mutable defaults\n\n    def __str__(self):\n        return f\"MyModel object with data: {self.data}\"\n","lang":"python","description":"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`."},"warnings":[{"fix":"Migrate to Django's built-in signal connection methods (e.g., `django.db.models.signals.post_save.connect`).","message":"The `annoying.decorators.signals` decorator is officially deprecated and will be removed in a future version. Django now includes native capabilities for signal handling, making this decorator redundant.","severity":"deprecated","affected_versions":"0.10.4+"},{"fix":"Remove the `autostrip` decorator and rely on Django's default form field behavior or explicitly set `strip=True` on `CharField` and `TextField`.","message":"The `annoying.decorators.autostrip` decorator is deprecated. Modern Django forms (CharField and Textarea) provide native stripping functionality by default (via `strip=True`).","severity":"deprecated","affected_versions":"0.10.4+"},{"fix":"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.","message":"Using a mutable object (like `dict` or `list`) directly as the `default` argument for `annoying.fields.JSONField` (or any Django field) will cause all model instances to share the *same* default object. Modifying it for one instance will affect all others.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"As of recent versions, `django-annoying` has dropped support for unmaintained and unsupported versions of Django. It explicitly requires Django 1.11 or later.","severity":"breaking","affected_versions":"< 0.10.4"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Provide a callable for the default, like `JSONField(default=dict)`. This ensures a fresh dictionary is created for each new model instance.","cause":"You've set a mutable dictionary directly as the `default` argument for `JSONField` (e.g., `JSONField(default={})`), leading to a shared default object and potential runtime errors when the system tries to call it as a callable.","error":"TypeError: 'dict' object is not callable when using JSONField default"},{"fix":"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.","cause":"When using `@render_to`, the decorator processes the return value of the view. If `Http404` is raised *after* the decorator's execution flow might have started or expects a dictionary, it can interfere with standard Django exception handling.","error":"Http404 is not caught or handled when using @render_to decorator"}]}