Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22473 closed Uncategorized (fixed)

Docs for Model.clean() are misleading

Reported by: anonymous Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from https://docs.djangoproject.com/en/1.6/ref/models/instances/#django.db.models.Model.clean


Model.clean()

This method should be used to provide custom model validation, and to modify attributes on your model if desired. For instance, you could use it to automatically provide a value for a field, or to do validation that requires access to more than a single field...


This is misleading, as it seems to say that Model.clean() is called when saving an object. It should be made clear here that clean() is for validation in forms.

Here's someone else who has run into this misunderstanding: http://stackoverflow.com/questions/18803112/django-doesnt-call-model-clean-method

Change History (3)

comment:1 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In b43bbd6d399c9ecca09c2e181715c8856ef5a598:

Fixed #22473 -- Emphasized that Model.clean() is not called from Model.save().

comment:2 by Tim Graham <timograham@…>, 10 years ago

In 839deb7a77a2321309da944031b7316322a0afbb:

[1.6.x] Fixed #22473 -- Emphasized that Model.clean() is not called from Model.save().

Backport of b43bbd6d39 from master

comment:3 by Tim Graham <timograham@…>, 10 years ago

In a9ad0818996f2c307f505dca68008841be06e0fc:

[1.7.x] Fixed #22473 -- Emphasized that Model.clean() is not called from Model.save().

Backport of b43bbd6d39 from master

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