{"id":21157,"library":"django-perf-rec","title":"django-perf-rec","description":"A Django library for recording and asserting performance characteristics of your code over time. It provides a Python context manager and Django test case mixin to record per-request SQL query counts and durations, template node counts, and response sizes. Version 4.31.0 supports Python 3.9+ and Django 3.2+. The project is actively maintained with a regular release cadence.","status":"active","version":"4.31.0","language":"python","source_language":"en","source_url":"https://github.com/adamchainz/django-perf-rec","tags":["django","performance","testing","sql-queries","assertions"],"install":[{"cmd":"pip install django-perf-rec","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Runtime dependency for Django integration","package":"django","optional":false}],"imports":[{"note":"Correct import location is at package level, not submodule.","wrong":"from django_perf_rec.mixin import RecordRequestsMixin","symbol":"RecordRequestsMixin","correct":"from django_perf_rec import RecordRequestsMixin"}],"quickstart":{"code":"from django_perf_rec import RecordRequestsMixin\nfrom django.test import TestCase\n\nclass MyTestCase(RecordRequestsMixin, TestCase):\n    def test_view(self):\n        response = self.client.get('/')\n        self.assertNumQueries(5)  # autmoatically records baseline\n        self.assertTemplateUsed('index.html')","lang":"python","description":"Basic usage with RecordRequestsMixin to automatically record and assert database query counts and templates."},"warnings":[{"fix":"Ensure mixin order: class MyTestCase(RecordRequestsMixin, TestCase):","message":"RecordRequestsMixin must be listed before TestCase in the base class order to work correctly.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to use RecordRequestsMixin for test classes or record_requests() for context managers.","message":"In version 4.0.0, the record() context manager was removed. Use the RecordRequestsMixin or record_requests() instead.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use assertNumQueries with the same signature.","message":"The attribute 'assertNumQueries' is deprecated in favor of 'assertNumQueries' but may be removed in a future version.","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use RecordRequestsMixin for test classes or record_requests() for context manager.","cause":"The record() context manager was removed in version 4.0.0.","error":"ImportError: cannot import name 'record' from 'django_perf_rec'"},{"fix":"Run 'pip install django-perf-rec' in your Python environment.","cause":"Library not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'django_perf_rec'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}