Ticket #10349: manytomany_dynamic_initial_against_1.0.2.diff
File manytomany_dynamic_initial_against_1.0.2.diff, 777 bytes (added by , 16 years ago) |
---|
-
django/db/models/fields/related.py
916 916 # If initial is passed in, it's a list of related objects, but the 917 917 # MultipleChoiceField takes a list of IDs. 918 918 if defaults.get('initial') is not None: 919 defaults['initial'] = [i._get_pk_val() for i in defaults['initial']] 919 initial = defaults['initial'] 920 if callable(initial): 921 initial = initial() 922 defaults['initial'] = [i._get_pk_val() for i in initial] 920 923 return super(ManyToManyField, self).formfield(**defaults) 921 924 922 925 def db_type(self):