Skip to content

Supposed caching problem #689

Description

@Tmpgmv

What you hit

from decimal import Decimal

from django.core.validators import MinValueValidator
from django.db import models

from app_requests.const import DEVICE_TYPES, STATUSES
from general.utils import choices

class AppRequest(models.Model):

client_name = models.CharField(max_length=100, verbose_name="ФИО клиента")
device_type = models.CharField(choices=choices(DEVICE_TYPES), verbose_name="Тип устройства")
problem_description = models.TextField(verbose_name="Описание неисправности")
status = models.CharField(choices=choices(STATUSES),
                          default=STATUSES[0],
                          verbose_name="Тип устройства")
estimated_price = models.DecimalField(validators=[MinValueValidator(Decimal(0.1)),],
                                      max_digits=10,
                                      decimal_places=2,
                                      verbose_name="Предварительная стоимость ремонта")


def __str__(self):
    return f"Id: {self.pk}"

class Meta:
    verbose_name = "Заявка"
    verbose_name_plural = "Заявки"
    ordering = ["pk"]
    db_table = "requests"

from rest_framework import serializers

from app_requests.models import AppRequest

class AppRequestSerializer(serializers.ModelSerializer):
class Meta:
model = AppRequest
fields = "all"

from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_control
from rest_framework import viewsets, permissions

from app_requests.models import AppRequest
from app_requests.serializers import AppRequestSerializer

@method_decorator(cache_control(private=True,
max_age=0,
no_cache=True,
no_store=True,
must_revalidate=True), name='dispatch')
class AppRequestViewSet(viewsets.ModelViewSet):
queryset = AppRequest.objects.all()
serializer_class = AppRequestSerializer
permission_classes = [permissions.AllowAny]

PREP {

cookiecutter
Django==5.2
django-plaintext-password==0.3.0 # https://pypi.org/project/django-plaintext-password/
pillow==12.0.0
django-resized==1.0.3 # https://pypi.org/project/django-resized/
django-cleanup==9.0.0 # https://pypi.org/project/django-cleanup/
django-bootstrap-icons==0.9.0 # https://pypi.org/project/django-bootstrap-icons/
django-jquery==3.1.0 # https://pypi.org/project/django-jquery/
psycopg2-binary==2.9.11
django-concurrency==2.7 # https://django-concurrency.readthedocs.io/en/latest/
selenium==4.40.0
pywebview==6.2.1 # https://pywebview.flowrl.com/
django-admin-react==1.13.1 # https://pypi.org/project/django-admin-react/
django-admin-rest-api==1.8.1 # https://pypi.org/project/django-admin-rest-api/
django-model-info==2026.3.1 # https://django-model-info.readthedocs.io/en/latest/

DRF { https://www.django-rest-framework.org/

djangorestframework==3.17.1
Markdown==3.10.2
django-filter==25.2

} DRF

} PREP

Problem: when I update the data in record, they are seemingly updated.

Have a look: 1(init).png, 2(init).png - initial state. Everything is in harmony.
I press "Edit" button: 3(edit_button_pressed).png. Everything is in harmony.
I change the price from 22.30 to 22.31.

Method is patch, payload is like this:

{
"client_name": "asdfasd",
"device_type": "Мобильный телефон",
"problem_description": "asdf",
"status": "В работе",
"estimated_price": "22.31"
}

The data in the database is updated.

I open the detail view of the record again (7(detail view).png). Everything is ok: 22.31 is visible.

I press the edit button again (8 (wrong data in the form).png). And here appears the error: in the form we can see the old price (22.30) despite the fact that the server returned 22.31 (which is visible in the screenshot.

The whole is here project (https://disk.yandex.ru/d/b624k01-UnmelA). Just create a database (have a look at maintenance/maintenance/secret.py). And just run. Then go to admin-react/.

Mount point

admin-react/

django-admin-react version

1.13.0

Django version

5.2

Custom AdminSite?

No — default django.contrib.admin.site

Surrounding URL config / middleware

No response

Admin shape that triggered it

Image Image Image Image Image Image Image Image

What you expected (legacy-admin parity)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions