You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, Django query instances cache their results so that subsequent calls to the same object do not hit the database. This is a behavior we rely on within ReactPy-Django to maintain ORM compatibility.
However, OrderedManyToMany does not seem to respect that same caching behavior as Django's built-in model fields. For example...
fromdjango.db.modelsimportprefetch_related_objectscategories=SpotlightCategory.objects.all()
# Initial run forces DB query execution to allow results to be stored in cacheforcategoryincategories:
# This should label the 'apps' field as a value that should be cachedprefetch_related_objects([category], 'apps')
print(category.name) # Call attribute to force `Model` to execute DB queriesprint(category.apps.get_queryset().all()) # Call the `QuerySet` to execute DB queries# Second run, everything should already be stored in cacheforcategoryincategories:
print(category.name) # This works as expected (the result is cached)print(category.apps.get_queryset().all()) # This causes a new query to be performed. It should have been cached.
The text was updated successfully, but these errors were encountered:
Original discussion: #277 (comment)
By default, Django query instances cache their results so that subsequent calls to the same object do not hit the database. This is a behavior we rely on within
ReactPy-Django
to maintain ORM compatibility.However,
OrderedManyToMany
does not seem to respect that same caching behavior as Django's built-in model fields. For example...The text was updated successfully, but these errors were encountered: