Ticket #5238: initial-default.diff
File initial-default.diff, 965 bytes (added by , 17 years ago) |
---|
-
django/newforms/models.py
77 77 determining the formfield for a given database field. It's a callable that 78 78 takes a database Field instance and returns a form Field instance. 79 79 """ 80 from django.db.models.fields import NOT_PROVIDED 81 80 82 opts = model._meta 81 83 field_list = [] 82 84 for f in opts.fields + opts.many_to_many: … … 86 88 continue 87 89 formfield = formfield_callback(f) 88 90 if formfield: 91 # Set the initial form field value based on the model field's default value. 92 if f.default != NOT_PROVIDED: 93 formfield.initial = f.default 89 94 field_list.append((f.name, formfield)) 90 95 base_fields = SortedDictFromList(field_list) 91 96 return type(opts.object_name + 'Form', (form,),