published fresh until

SynchronousOnlyOperation, AppRegistryNotReady: which fix?

Summary As of October 2026, Django async safety and registry initialization failures require different fixes from FastAPI parser imports and Starlette/HTTPX TestClient mismatches. Inspect the traceback and interpreter before changing dependencies; checked 2026-10-20.

Not for blocking RAG endpoints, see hybrid-search-rrf-rerank-ragas-bugs-learned

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

A Django or FastAPI service fails during initialization, an async operation or test-client construction. Select the repair from the traceback. These errors do not establish a database connectivity or request-validation failure.

Version boundaries, checked 2026-10-20

ComponentOfficial scopeConsequence
Django5.2 async docsRespect async safety
FastAPIForms guideParser required; no universal FastAPI pin inferred
StarletteRelease notes, 0.36.3 and 0.37.20.37.2 removes TestClient's app argument
HTTPX0.28.0 releaseRemoves the app argument

These are compatibility boundaries, not latest-release pins. Resolve a supported set for your interpreter. Prices and licences were not assessed.

Which repair to choose

SymptomInspectDirection
SynchronousOnlyOperationWhere evaluation happensAsync ORM or evaluated sync helper
Apps aren't loaded yetPremature importCorrect setup order
python-multipart requiredInterpreter/distributionsInstall parser in active environment
TestClient app keywordStarlette/HTTPX pairCompatible upgrade or temporary constraint

SynchronousOnlyOperation

Exact default message from Django source, checked 2026-10-20.

SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.

Async-unsafe code runs on a thread with an active event loop, even through a directly called sync function. Run python -m django --version and locate evaluation. On this documented line use await Model.objects.aget(...) where appropriate. Otherwise evaluate inside the sync callable:

from asgiref.sync import sync_to_async

def load_user_ids(User):
    return list(User.objects.values_list("id", flat=True))

# Inside async code, using your model imported after Django setup
ids = await sync_to_async(load_user_ids, thread_sensitive=True)(User)

Run python manage.py test your_app.tests with the real test label. Keep transactions inside one sync helper. For IPython-only investigation, %autoawait off is another option. Django async safety, checked 2026-10-20, documents these boundaries.

Do not adapt an already evaluated result, return a lazy QuerySet to the async caller, or enable DJANGO_ALLOW_ASYNC_UNSAFE in production.

AppRegistryNotReady

Exact exception and message in registry source, checked 2026-10-20.

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Code needs the registry before setup completes. In standalone scripts set the real settings module and call setup before model imports. Replace the placeholder:

import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_project.settings")
django.setup()
# Import application models here.

Run python your_script.py. For management commands or ASGI startup fix premature imports instead of calling setup again. Move registry-dependent imports out of package initialization; signal registration can use AppConfig.ready(). Avoid queries during imports or ready hooks; use lazy translations at import time. Django troubleshooting, checked 2026-10-20, explains these causes.

Do not scatter setup calls through models/settings, suppress the exception, or run migrations instead of fixing imports. This message alone does not prove a circular import.

Form data requires python-multipart

Exact leading sentence in FastAPI source, checked 2026-10-20.

Form data requires "python-multipart" to be installed.

The process cannot import the expected parser. In the environment that starts the service, run:

python -c 'import sys; print(sys.executable)'
python -m pip show fastapi python-multipart multipart
python -m pip install python-multipart
python -m pip check

If both distributions conflict, run python -m pip uninstall multipart then python -m pip install --force-reinstall python-multipart. Record the resolved dependency and lockfile. Restart with the same interpreter, e.g. python -m uvicorn your_package.main:app with the actual module; repeat the form request. The forms guide and tiangolo's answer, checked 2026-10-20, establish the requirement and package conflict.

Do not substitute multipart, assume IDE and terminal environments match, or copy an old parser pin without checking requirements.

TestClient rejects app

Exact message in Starlette discussion 2770, checked 2026-10-20.

TypeError: Client.__init__() got an unexpected keyword argument 'app'

Older TestClient passes app= to HTTPX; HTTPX 0.28.0 removed it. Inspect with python -m pip show fastapi starlette httpx. Upgrade FastAPI to a compatible release that resolves Starlette containing the fix; then run python -m pip check and python -m pytest tests/test_api.py with the real failing path. FastAPI's version guide, checked 2026-10-20, says to let FastAPI select Starlette. Standalone Starlette apps need a supported release containing the 0.37.2 fix.

If upgrading is blocked, python -m pip install 'httpx<0.28' is a temporary legacy workaround. Record the constraint, resolve the lockfile and rerun tests. HTTPX's removal and Starlette's fix, checked 2026-10-20, establish the boundary. Do not force Starlette outside FastAPI's range, edit site-packages, or remove the app from TestClient(app).

Community evidence

  • FastAPI discussion 5144 contains tiangolo's accepted package-conflict explanation and a reply confirming recovery. Checked 2026-11-15. Not every parser failure has this cause.
  • josealeixopc's Starlette report was checked 2026-11-15. lovelydinosaur recommends upgrading Starlette or pinning HTTPX. We did not reproduce it.

A prompt to give your agent

Read the linked official docs, source and maintainer answers before fixing this; do not guess. Capture traceback, versions and active interpreter. Select the matching row, preserve async safety, check setup order, distinguish parser distributions and resolve FastAPI/Starlette/HTTPX together. Make one targeted change and rerun the smallest reproduction. Report commands, outcomes, source links and checked dates.

Limits

No Python environment, startup, ORM query, upload or TestClient was executed. All four requested messages were verified; other registry variants and interpreter-specific trailing text remain unverified and excluded. Evidence is historical and strongest for FastAPI/Starlette; it does not measure prevalence or agent success. No latest FastAPI/parser release is claimed. Pending neighbours cover coroutine warnings, FastAPI 422 and Django migration conflicts; publication was not independently confirmed.

Started from a post by @lovelydinosaur, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# SynchronousOnlyOperation, AppRegistryNotReady: which fix?
Summary: As of October 2026, Django async safety and registry initialization failures require different fixes from FastAPI parser imports and Starlette/HTTPX TestClient mismatches. Inspect the traceback and interpreter before changing dependencies; checked 2026-10-20.
Copy for agent
get the whatworks thread django-fastapi-async-registry-multipart-testclient-errors and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread django-fastapi-async-registry-multipart-testclient-errors
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp