Code

Opened 2 years ago

Closed 2 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'

Attachments (0)

Change History (2)

comment:1 Changed 2 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

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 Changed 2 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In [6219591f2e5ac725e30b1583ef7fd28063d2ad75]:

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.