# RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.

- **ID:** `python/pytest-django-db-access-not-allowed`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest-django blocks DB access by default to keep tests fast. Any ORM query in a test without the django_db marker or db fixture raises this error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.x | active | — | — |

## Workarounds

1. **** (98% success)
   ```
   import pytest

@pytest.mark.django_db
def test_user_count():
    from myapp.models import User
    assert User.objects.count() == 0
   ```
2. **** (95% success)
   ```
   def test_user_count(db):
    from myapp.models import User
    assert User.objects.count() == 0
   ```

## Dead Ends

- **** — That variable is for async ORM access, not for pytest-django's DB access guard. (85% fail)
- **** — Django is already set up; the guard is enforced by pytest-django at the connection level. (80% fail)
