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

- **ID:** `python/pytest-django-database-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 and isolated. Any ORM call in a test without @pytest.mark.django_db or the db fixture raises this failure.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.8 | active | — | — |

## Workarounds

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

@pytest.mark.django_db
def test_create_user():
    User.objects.create(email='a@b.com')
    assert User.objects.count() == 1
   ```
2. **** (96% success)
   ```
   def test_create_user(db):
    User.objects.create(email='a@b.com')
    assert User.objects.count() == 1
   ```

## Dead Ends

- **** — The block is enforced by pytest-django's plugin, not by the database backend; the failure occurs before any connection is attempted. (90% fail)
- **** — NameError: name 'pytest' is not defined, or the mark is silently ignored if imported incorrectly. (80% fail)
