10

I have a Django page called /candidates which is supposed to fetch all Candidate entries in the database.

The problem is whenever I create a new Candidate entry, the /candidates page doesn't show anything but when I check django-admin I can verify that the new entry was in fact created successfully. But it doesn't reflect on the page I created. I had to restart apache before the /candidates page can actually show the newly created entries.

Is there a new feature on Django 1.7 that causes this behavior? I haven't encountered this in previous versions.

bignose
  • 30,281
  • 14
  • 77
  • 110
DigitalDouble
  • 1,747
  • 14
  • 26
  • 5
    do you have any caching going on ? – nehz May 05 '15 at 02:32
  • 1
    I don't think so unless Django enables it by default. And just to be sure I just checked my `settings` and `templates` and I can't find the string `"cache"`. – DigitalDouble May 05 '15 at 02:46
  • 5
    try django's server directly without apache and check what kind of response your getting in your browser dev tools – nehz May 05 '15 at 02:52
  • 5
    I would also check the HTTP cache, not only server-side cache. For this, just use the F12 Tools Inside your browser of choice, go to the network tab or equivalent, and check 1) if the page is really reladed 2) if the return code is NOT MODIFIED 3) The cache header of the answer, and potentially the ETAG. Checking if emptying Navigator cache + restart solves the issue would be helpful too – Marcanpilami May 11 '15 at 07:48
  • 5
    try adding a query string parameter like /candidates?v=1 to check if it is a cache issue ? – Charlesthk May 11 '15 at 19:55
  • 2
    Are you re-using a QuerySet like this? https://docs.djangoproject.com/en/1.11/topics/db/queries/#caching-and-querysets, or perhaps in some way you are fetching the result set once at the module level so each call is getting the same result? – Neil Anderson Jun 05 '17 at 16:40
  • To reiterate @NeilAnderson 's point: if you create the QuerySet at the top level of a module, it will evaluate when you first import that module (or the first time that QuerySet is accessed), and may not re-evaluate in the future. – Matthew Schinckel Mar 11 '20 at 11:09

0 Answers0