Ticket #17122: 2011.10.28_2206.diff
File 2011.10.28_2206.diff, 2.7 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/widgets.py
130 130 131 131 def render(self, name, value, attrs=None): 132 132 rel_to = self.rel.to 133 # custom fields may need the to_python 134 # conversion in order to facilitate 135 # unicode conversion 136 try: 137 value = self.rel.to._meta.get_field(self.rel.field_name).to_python(value) 138 except AttributeError: 139 pass# 'ManyToManyRel' object has no attribute 'field_name' 133 140 if attrs is None: 134 141 attrs = {} 135 142 extra = [] … … 139 146 (rel_to._meta.app_label, 140 147 rel_to._meta.module_name), 141 148 current_app=self.admin_site.name) 142 149 143 150 params = self.url_parameters() 144 151 if params: 145 152 url = u'?' + u'&'.join([u'%s=%s' % (k, v) for k, v in params.items()]) … … 248 255 249 256 def render(self, name, value, *args, **kwargs): 250 257 rel_to = self.rel.to 258 # custom fields may need the to_python 259 # conversion in order to facilitate 260 # unicode conversion 261 try: 262 value = self.rel.to._meta.get_field(self.rel.field_name).to_python(value) 263 except AttributeError: 264 pass# 'ManyToManyRel' object has no attribute 'field_name' 251 265 info = (rel_to._meta.app_label, rel_to._meta.object_name.lower()) 252 266 self.widget.choices = self.choices 253 267 output = [self.widget.render(name, value, *args, **kwargs)] -
django/forms/forms.py
341 341 hidden_widget = field.hidden_widget() 342 342 initial_value = hidden_widget.value_from_datadict( 343 343 self.data, self.files, initial_prefixed_name) 344 # custom fields may need the to_python 345 # conversion in order to facilitate 346 # unicode conversion 347 if isinstance(initial_value,list): 348 # ManyToManyField uses a list 349 initial_value = [field.to_python(v) for v in initial_value] 350 else: 351 initial_value = field.to_python(initial_value) 344 352 if field.widget._has_changed(initial_value, data_value): 345 353 self._changed_data.append(name) 346 354 return self._changed_data