﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37504	Avoid circular import when importing django.db.backends.sqlite3.features directly	Alexis Román		"Importing `django.db.backends.sqlite3.features` directly before `django.db.backends.sqlite3.base` raises an `ImportError` due to a circular import on `main` (tested on CPython 3.12.13 with `asgiref` installed):

{{{
$ python -c ""import django.db.backends.sqlite3.features""
ImportError: cannot import name 'DatabaseFeatures' from partially initialized module 'django.db.backends.sqlite3.features' (most likely due to a circular import)
}}}

=== Root cause ===
* `django/db/backends/sqlite3/features.py` (line 10) executes `from .base import Database`.
* `django/db/backends/sqlite3/base.py` imports `DatabaseFeatures` from `.features` and already aliases `from sqlite3 import dbapi2 as Database` (line 11).

Normal startup via `django/db/utils.py` hides the cycle because `.base` is loaded first, whereas modules that import `sqlite3.features` directly (such as `django/contrib/gis/db/backends/spatialite/features.py`) hit the circular import.

=== Proposed fix ===
In `django/db/backends/sqlite3/features.py`, import `Database` directly from `sqlite3` instead of `.base`:

{{{
from sqlite3 import dbapi2 as Database
}}}"	Bug	new	Database layer (models, ORM)	dev	Normal		sqlite3 circular-import		Unreviewed	0	0	0	0	0	0
