dj-inmemorystorage is a non-persistent in-memory data storage backend for Django, providing compatibility with Django's storage API. It is primarily used for testing purposes to avoid disk access and speed up test suites. The library is currently at version 2.1.0 and has an irregular release cadence, often tied to updates in Django and Python version support, as well as feature additions.
pip install dj-inmemorystorageVerified import paths — ran on the pinned version, not inferred.
To use dj-inmemorystorage, configure your Django settings (typically in `settings.py` or a test settings file) by setting `DEFAULT_FILE_STORAGE` to `'inmemorystorage.InMemoryStorage'`. By default, the storage is non-persistent; enable `INMEMORYSTORAGE_PERSIST = True` if you need writes to be retained across operations within the same storage instance. The example demonstrates saving, checking existence, reading, and deleting a file using the configured default storage.
Upgrade Python to 3.7 or newer and Django to 2.2 or newer before upgrading dj-inmemorystorage to 2.0.0 or later.
To enable persistence across operations within the same storage instance, set `INMEMORYSTORAGE_PERSIST = True` in your Django settings, e.g., `INMEMORYSTORAGE_PERSIST = True`.
Upgrade to `dj-inmemorystorage` version 2.1.0 or later to ensure proper compatibility with Django migrations and class serialization.
Ensure the package is installed: `pip install dj-inmemorystorage`. Double-check your `settings.py` for `DEFAULT_FILE_STORAGE = 'inmemorystorage.InMemoryStorage'` to ensure it's correctly spelled and pointing to the right location.
In your Django settings, add `INMEMORYSTORAGE_PERSIST = True` to enable persistence for the in-memory storage instance. Remember that even with persistence, data is lost when the application restarts.
Update `dj-inmemorystorage` to version 2.1.0 or newer. If issues persist, you might need to run `makemigrations` and `migrate` again after the upgrade, or consider manual migration adjustments if the storage was previously referenced in model fields.