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

- **ID:** `python/pytest-django-fixture-db-access`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest-django blocks database access by default. The test tries to query the database without the django_db mark or db fixture.

## Version Compatibility

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

## Workarounds

1. **** (98% success)
   ```
   @pytest.mark.django_db
def test_create_user():
    User.objects.create(username='test')
   ```
2. **** (95% success)
   ```
   def test_create_user(db):
    User.objects.create(username='test')
   ```
3. **** (90% success)
   ```
   @pytest.mark.django_db(transaction=True)
def test_transaction():
    ...
   ```

## Dead Ends

- **** — The block is enforced by pytest-django, not Django settings. (90% fail)
- **** — Breaks Django test integration and may cause other failures. (95% fail)
- **** — pytest-django still applies the block unless marked. (80% fail)
