python - Django caching queries (I don't want it to) -


so i'm working in python/django , have problem django caches querysets "within session".

if run python manage.py shell , so:

>>> myproject.services.models import * >>> test = testmodel.objects.filter(pk = 5) >>> print test[0].name >>> john 

now, if update directly in sql bob , run again, it'll still john. if ctrl+d out (exit) , run same thing, have updated , print bob.

my problem i'm running soap service in screen , it'll return same result, if data gets changed.

i need way force query pull data database again, not pull cached data. use raw queries doesn't feel solution me, ideas?

the queryset not cached 'within session'.

the django documentation: caching , querysets mentions:

each queryset contains cache minimize database access. understanding how works allow write efficient code.

in newly created queryset, cache empty. first time queryset evaluated – and, hence, database query happens – django saves query results in queryset’s cache , returns results have been explicitly requested (e.g., next element, if queryset being iterated over). subsequent evaluations of queryset reuse cached results.

keep caching behavior in mind, because may bite you if don’t use querysets correctly.

(emphasis mine)

for more information on when querysets evaluated, refer this link.

if critical application querysets gets updated, have evaluate each time, within single view function, or ajax.

it running sql query again , again. old times when no querysets have been available , kept data in structure had refresh.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -