'CACHE_URL' default value is not found using env.cache()
See original GitHub issueHi,
The environment: django-environ==0.4.4 Django==2.0.6
I have no CACHE_URL
environment variable set in the system.
In settings.py I use:
env = environ.Env(
DEBUG=(bool, False),
CACHE_URL=(str, "locmemcache://"),
)
On calling env.cache()
I expect to get a dictinoary like this:
{'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': ''}
Instead I get:
raise KeyError(key) from None
KeyError: 'CACHE_URL'
print(env('CACHE_URL'))
shows the correct default value.
print(os.environ['CACHE_URL'])
raises a KeyError
.
In the python shell the above workflow works perfectly - env.cache()
returns what is expected.
Am I missing something?
Thanks, Norman
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
The "" cache configuration does not exist - Stack Overflow
I don't understand why the code tries to search for a configuration with empty string "" . Here is the relevant part of...
Read more >API Reference - django-environ
Callable or None) – Type to cast return value as. default – If var not present in environ, return this instead. parse_default (bool)...
Read more >Using the Cache API · Cloudflare Workers docs
const cache = caches.default;. // Check whether the value is already available in the cache. // if not, you will need to fetch...
Read more >Code Samples - Ehcache
When the CacheManager is created it creates caches found in the configuration. Create a CacheManager using defaults. Ehcache will look for ehcache.xml in...
Read more >Configuring Django Settings: Best Practices
No inheritance in settings, and cleaner and more consistent code. There is a theoretical grounding for using Django environment variables – 12 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mehdy Ah, PRs are always welcome!
I’m closing since this is a not a bug, but if I have made an oversight, please do get back in touch. Thanks.