Ticket #1084: db.diff

File db.diff, 3.5 KB (added by Nebojša Đorđević - nesh <nesh@…>, 18 years ago)
  • django/db/models/base.py

     
    1010from django.dispatch import dispatcher
    1111from django.core.exceptions import ObjectDoesNotExist
    1212from django.utils.functional import curry
     13from django.conf import settings
    1314import re
    1415import types
    1516import sys
  • django/db/models/manipulators.py

     
    11from django.core.exceptions import ObjectDoesNotExist
     2from django.core import formfields
    23from django.core.formfields import Manipulator
    34from django.db.models.fields import FileField, AutoField
     5from django.db.models.fields.related import ManyToOne
    46from django.dispatch import dispatcher
    57from django.db.models import signals
     8from django.utils.functional import curry
    69
    710def add_manipulators(sender):
    811    cls = sender
     
    5154        cls.manager = model._default_manager
    5255        cls.opts = model._meta
    5356        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))
    5558        for f in cls.opts.fields:
    5659            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'))
    5861            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'))
    6063            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'))
    6265    _prepare = classmethod(_prepare)
    6366
    6467    def contribute_to_class(cls, other_cls, name ):
     
    310313
    311314def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_type, self, field_data, all_data):
    312315    date_str = all_data.get(date_field.get_manipulator_field_names('')[0], None)
    313     mod = opts.get_model_module()
     316    mod = opts.model
    314317    date_val = formfields.DateField.html2python(date_str)
    315318    if date_val is None:
    316319        return # Date was invalid. This will be caught by another validator.
     
    324327    if lookup_type == 'date':
    325328        lookup_kwargs['%s__day' % date_field.name] = date_val.day
    326329    try:
    327         old_obj = mod.get_object(**lookup_kwargs)
     330        old_obj = mod._default_manager.get_object(**lookup_kwargs)
    328331    except ObjectDoesNotExist:
    329332        return
    330333    else:
Back to Top