Ticket #13717: 13717_fix_unique_for.diff
File 13717_fix_unique_for.diff, 1.3 KB (added by , 14 years ago) |
---|
-
db/models/base.py
798 798 # there's a ticket to add a date lookup, we can remove this special 799 799 # case if that makes it's way in 800 800 date = getattr(self, unique_for) 801 if lookup_type == 'date': 802 lookup_kwargs['%s__day' % unique_for] = date.day 803 lookup_kwargs['%s__month' % unique_for] = date.month 804 lookup_kwargs['%s__year' % unique_for] = date.year 801 if date: 802 if lookup_type == 'date': 803 lookup_kwargs['%s__day' % unique_for] = date.day 804 lookup_kwargs['%s__month' % unique_for] = date.month 805 lookup_kwargs['%s__year' % unique_for] = date.year 806 else: 807 lookup_kwargs['%s__%s' % (unique_for, lookup_type)] = getattr(date, lookup_type) 805 808 else: 806 lookup_kwargs[ '%s__%s' % (unique_for, lookup_type)] = getattr(date, lookup_type)809 lookup_kwargs[unique_for] = None 807 810 lookup_kwargs[field] = getattr(self, field) 808 811 809 812 qs = model_class._default_manager.filter(**lookup_kwargs)