Opened 15 months ago

Last modified 4 months ago

#27654 new Cleanup/optimization

Propogate alters_data value to subclasses

Reported by: vinay karanam Owned by: nobody
Component: Core (Other) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Current implementation to prevent data changes within templates relies on the attribute alters_data = True.

By default this is set for all Model, QuerySet and ModelForm methods that can alter data.

But if someone overrides these methods, they need to explicitly set this attribute again.
It is common to override save method and not set this attribute.

Even a lot of popular third-party packages end up making this mistake.

These classes need to make sure that the attribute value is set for their subclasses methods if not explicitly overwritten.

Change History (2)

comment:1 Changed 15 months ago by Tim Graham

Component: UncategorizedCore (Other)
Patch needs improvement: set
Triage Stage: UnreviewedAccepted


This ticket is a result of discussion in #27638 which suggested to solve the problem by issuing a rollback after rendering templates (closed as wontfix).

Last edited 15 months ago by Tim Graham (previous) (diff)

comment:2 Changed 4 months ago by Asif Saifuddin Auvi

Patch needs improvement: unset
Version: 1.10master
Note: See TracTickets for help on using tickets.
Back to Top