Opened 8 years ago

Last modified 8 years ago

#27446 closed New feature

Addition of `readonly` option to ModelField to allow database generated fields — at Version 1

Reported by: Ben Cole Owned by: Ben Cole
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: ewjoachim@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ben Cole)

There exist multiple use cases where a database will generate values for a field/column. Most RDBMSes expect that these columns be excluded from from INSERT and UPDATE statements. However they still need to be included in SELECT statements.

The proposal therefore is to add a readonly option to the base Field class that when True would strip these fields from being compiled to SQL during INSERTs and UPDATEs. This allows for a very simple change that covers all possible write queries that Django may perform (including bulk_*).

There exists a proof of concept https://github.com/novafloss/django-readonly-field

Change History (1)

comment:1 by Ben Cole, 8 years ago

Description: modified (diff)
Owner: changed from nobody to Ben Cole
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top