Opened 10 years ago

Closed 9 years ago

#3105 closed enhancement (invalid)

[patch]: Support for additional model.Field setting (update=True|False).

Reported by: Eric Van Dewoestine <ervandew@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Patch based on development version 4051.

The attached patches add support for an additional model field argument (update=True|False, defaulting to True) which allows the user to mark fields which should or should not be include in any update statements made on behalf of the model.

This is especially useful if the field in question is managed via an external process (like a database trigger).

Ex.

class Poll (models.Model):
  totalVotes = models.IntegerField(default=0, editable=False, update=False)

In the above example the totalVotes column would never be included in django's update sql statement to the database.

For completeness, you may want to add a corresponding insert=True|False which applies the same rules to insert sql statements.

Attachments (2)

base.py.diff (1.6 KB) - added by Eric Van Dewoestine <ervandew@…> 10 years ago.
django/db/models/base.py.diff
__init__.py.diff (1.2 KB) - added by Eric Van Dewoestine <ervandew@…> 10 years ago.
django/db/models/fields/init.py.diff

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by Eric Van Dewoestine <ervandew@…>

Attachment: base.py.diff added

django/db/models/base.py.diff

Changed 10 years ago by Eric Van Dewoestine <ervandew@…>

Attachment: __init__.py.diff added

django/db/models/fields/init.py.diff

comment:1 Changed 10 years ago by Simon G. <dev@…>

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 9 years ago by James Bennett

Resolution: invalid
Status: newclosed

This really feels like specialized behavior that should be handled in a custom save method, not in Django's core.

Note: See TracTickets for help on using tickets.
Back to Top