Ticket #2965: ticket-2965.patch
File ticket-2965.patch, 1.6 KB (added by , 18 years ago) |
---|
-
django/db/models/manipulators.py
old new 286 286 # This is really not going to work for fields that have different 287 287 # form fields, e.g. DateTime. 288 288 # This validation needs to occur after html2python to be effective. 289 field_val = all_data.get(f.attname, None)290 if field_val is None:289 field_val = f.get_manipulator_new_data(all_data) 290 if not f.null and field_val is None: 291 291 # This will be caught by another validator, assuming the field 292 292 # doesn't have blank=True. 293 293 return 294 294 if isinstance(f.rel, ManyToOneRel): 295 kwargs[ '%s__pk' % f.name] = field_val295 kwargs[f.get_validator_unique_lookup_type()] = field_val 296 296 else: 297 297 kwargs['%s__iexact' % f.name] = field_val 298 298 try: … … 303 303 pass 304 304 else: 305 305 raise validators.ValidationError, _("%(object)s with this %(type)s already exists for the given %(field)s.") % \ 306 {'object': capfirst(opts.verbose_name), 'type': field_list[0].verbose_name, 'field': get_text_list([f.verbose_name for f in field_list[1:]], 'and')}306 {'object': capfirst(opts.verbose_name), 'type': field_list[0].verbose_name, 'field': get_text_list([f.verbose_name for f in field_list[1:]], _('and'))} 307 307 308 308 def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_type, self, field_data, all_data): 309 309 from django.db.models.fields.related import ManyToOneRel