Opened 13 years ago

Closed 12 years ago

#18244 closed Bug (fixed)

example in django formsets doesn't work

Reported by: pedropaulosbs@… Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

tried the example available at https://docs.djangoproject.com/en/dev/topics/forms/formsets/#formset-validation. the method "has_changed" should return True or False but instead, raise an exception.

Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django import forms
>>> class ArticleForm(forms.Form):
...    title = forms.CharField()
...    pub_date = forms.DateField()
... 
>>> from django.forms.formsets import formset_factory
>>> ArticleFormSet = formset_factory(ArticleForm)
>>> data = {
...   'form-TOTAL_FORMS': u'2',
...   'form-INITIAL_FORMS': u'0',
...   'form-MAX_NUM_FORMS': u'',
...   'form-0-title': u'Test',
...   'form-0-pub_date': u'1904-06-16',
...   'form-1-title': u'Test',
...   'form-1-pub_date': u'',
... }
>>> formset = ArticleFormSet(data)
>>> formset.has_changed()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'ArticleFormFormSet' object has no attribute 'has_changed'

Change History (2)

comment:1 by Karen Tracey, 13 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

The problem is that the has_changed method for formsets was added after 1.3 (in r16773). The documentation should note that has_changed for formsets is new in 1.4.

comment:2 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [6219591f2e5ac725e30b1583ef7fd28063d2ad75]:

Fixed #18244 -- Documented that formset.has_changed is a 1.4 addition.

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