Ticket #4018: django-make-initial-newforms-value-callable.diff

File django-make-initial-newforms-value-callable.diff, 987 bytes (added by David Danier <goliath.mailinglist@…>, 18 years ago)
  • django/newforms/forms.py

    ==== Patch <django-make-initial-newforms-value-callable> level 1
    Source: 6666b74b-a72c-0410-9b74-dd6beae1e16f:/django/make-initial-newforms-value-callable:5942 [local]
    Target: bcc190cf-cafb-0310-a4f2-bffc1f526a37:/django/trunk:4993 [mirrored]
            (http://code.djangoproject.com/svn/django/trunk)
    Log:
     r5942@damasonium:  ddanier | 2007-04-12 10:08:37 +0200
      * Initial value for newforms-fields may be callable now
    
    === django/newforms/forms.py
    ==================================================================
     
    248248            attrs['id'] = auto_id
    249249        if not self.form.is_bound:
    250250            data = self.form.initial.get(self.name, self.field.initial)
     251            if callable(data):
     252                data = data()
    251253        else:
    252254            data = self.data
    253255        return widget.render(self.html_name, data, attrs=attrs)
Back to Top