Registry / web-framework / django-annoying

django-annoying

JSON →
library0.10.8pypypi✓ verified 90d ago

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-annoying
INSTALL
IMPORT
SIG · DJANGO-ANNOYING
D
django-annoying
web-frameworkpythonv0.10.8
Install
3.5s avg
Import
640ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.10.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.681s · 66.4MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 3.5s · import 0.598s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

render_to
✓ from annoying.decorators import render_to
ajax_request
✓ from annoying.decorators import ajax_request
JSONField
✓ from annoying.fields import JSONField
AutoOneToOneField
✓ from annoying.fields import AutoOneToOneField
get_object_or_None
✓ from annoying.functions import get_object_or_None
signals
✓ from annoying.decorators import signals
✗ from django.db.models import signals
The `annoying.decorators.signals` is deprecated. Modern Django has native signal handling, or it may be confused with standard Django signals.
autostrip
✓ from annoying.decorators import autostrip
✗ from django import forms
The `annoying.decorators.autostrip` is deprecated. Modern Django forms handle stripping natively.

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}"
Debug
Known issues
deprecatedThe `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.
fix
Migrate to Django's built-in signal connection methods (e.g., `django.db.models.signals.post_save.connect`).
affects: 0.10.4+
deprecatedThe `annoying.decorators.autostrip` decorator is deprecated. Modern Django forms (CharField and Textarea) provide native stripping functionality by default (via `strip=True`).
fix
Remove the `autostrip` decorator and rely on Django's default form field behavior or explicitly set `strip=True` on `CharField` and `TextField`.
affects: 0.10.4+
gotchaUsing 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.
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.
affects: All versions
breakingAs of recent versions, `django-annoying` has dropped support for unmaintained and unsupported versions of Django. It explicitly requires Django 1.11 or later.
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.
affects: < 0.10.4
Errors
Common errors & fixes
TypeError: 'dict' object is not callable when using JSONField default
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.
fix
Provide a callable for the default, like `JSONField(default=dict)`. This ensures a fresh dictionary is created for each new model instance.
Http404 is not caught or handled when using @render_to decorator
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.
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.
Upgrade
Version history
0.10.8latest on PyPI · released Apr 3, 2025
Audit
Dependencies
DjangorequiredCore functionality relies on the Django framework; requires Django 1.11 or later.
Agent activity
10 hits · last 30 days
node
8
Resources
django-annoying — pip install django-annoying · libregistry