question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'CACHE_URL' default value is not found using env.cache()

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sergeyklaycommented, Oct 5, 2021

@mehdy Ah, PRs are always welcome!

0reactions
sergeyklaycommented, Oct 6, 2021

I’m closing since this is a not a bug, but if I have made an oversight, please do get back in touch. Thanks.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found