Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Cache settings override does not work

This is my cache setting:

ENABLE_CACHING = True

if ENABLE_CACHING:
    CACHES = get_cache()
else:
    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
        }
    }

I tried to override this setting in two ways:

@override_settings(ENABLE_CACHING=False)

@override_settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}})
class IndexViewTests(TestCase):
    def test_index_view_with_a_future_question(self):
        """
        Questions with a pub_date in the future should not be displayed on
        the index page.
        """
        create_question('Future question', 1,
                        [Choice(choice_text='Dummy choice')])
        response = self.client.get(reverse('polls:index'))
        self.assertEqual(response.status_code, 200)
        self.assertQuerysetEqual(response.context['latest_questions'], [])
        self.assertEqual(response.context['total_questions'], 1)
        self.assertEqual(response.context['total_votes'], 0)

Both do not override the settings and I have to do it manually again. How can this be fixed? This is a example failed test result caused by enabled caching:

ERROR: test_index_view_with_a_future_question (polls.tests.IndexViewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/david/Projects/easypolls/polls/tests.py", line 375, in test_index_view_with_a_future_question
    self.assertQuerysetEqual(response.context['latest_questions'], [])
TypeError: 'NoneType' object is not subscriptable
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!