Ticket #1084: db.diff
File db.diff, 3.5 KB (added by , 19 years ago) |
---|
-
django/db/models/base.py
10 10 from django.dispatch import dispatcher 11 11 from django.core.exceptions import ObjectDoesNotExist 12 12 from django.utils.functional import curry 13 from django.conf import settings 13 14 import re 14 15 import types 15 16 import sys -
django/db/models/manipulators.py
1 1 from django.core.exceptions import ObjectDoesNotExist 2 from django.core import formfields 2 3 from django.core.formfields import Manipulator 3 4 from django.db.models.fields import FileField, AutoField 5 from django.db.models.fields.related import ManyToOne 4 6 from django.dispatch import dispatcher 5 7 from django.db.models import signals 8 from django.utils.functional import curry 6 9 7 10 def add_manipulators(sender): 8 11 cls = sender … … 51 54 cls.manager = model._default_manager 52 55 cls.opts = model._meta 53 56 for field_name_list in cls.opts.unique_together: 54 setattr(cls, 'isUnique%s' % '_'.join(field_name_list), curry(manipulator_validator_unique_together, field_name_list, opts))57 setattr(cls, 'isUnique%s' % '_'.join(field_name_list), curry(manipulator_validator_unique_together, field_name_list, cls.opts)) 55 58 for f in cls.opts.fields: 56 59 if f.unique_for_date: 57 setattr(cls, 'isUnique%sFor%s' % (f.name, f.unique_for_date), curry(manipulator_validator_unique_for_date, f, opts.get_field(f.unique_for_date),opts, 'date'))60 setattr(cls, 'isUnique%sFor%s' % (f.name, f.unique_for_date), curry(manipulator_validator_unique_for_date, f, cls.opts.get_field(f.unique_for_date), cls.opts, 'date')) 58 61 if f.unique_for_month: 59 setattr(cls, 'isUnique%sFor%s' % (f.name, f.unique_for_month), curry(manipulator_validator_unique_for_date, f, opts.get_field(f.unique_for_month),opts, 'month'))62 setattr(cls, 'isUnique%sFor%s' % (f.name, f.unique_for_month), curry(manipulator_validator_unique_for_date, f, cls.opts.get_field(f.unique_for_month), cls.opts, 'month')) 60 63 if f.unique_for_year: 61 setattr(cls, 'isUnique%sFor%s' % (f.name, f.unique_for_year), curry(manipulator_validator_unique_for_date, f, opts.get_field(f.unique_for_year),opts, 'year'))64 setattr(cls, 'isUnique%sFor%s' % (f.name, f.unique_for_year), curry(manipulator_validator_unique_for_date, f, cls.opts.get_field(f.unique_for_year), cls.opts, 'year')) 62 65 _prepare = classmethod(_prepare) 63 66 64 67 def contribute_to_class(cls, other_cls, name ): … … 310 313 311 314 def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_type, self, field_data, all_data): 312 315 date_str = all_data.get(date_field.get_manipulator_field_names('')[0], None) 313 mod = opts. get_model_module()316 mod = opts.model 314 317 date_val = formfields.DateField.html2python(date_str) 315 318 if date_val is None: 316 319 return # Date was invalid. This will be caught by another validator. … … 324 327 if lookup_type == 'date': 325 328 lookup_kwargs['%s__day' % date_field.name] = date_val.day 326 329 try: 327 old_obj = mod. get_object(**lookup_kwargs)330 old_obj = mod._default_manager.get_object(**lookup_kwargs) 328 331 except ObjectDoesNotExist: 329 332 return 330 333 else: