'Return any additional field options that need to be included as a
result of uniqueness constraints on the model. This is returned as
a two-tuple of:
(\'dict of updated extra kwargs\', \'mapping of hidden fields\')'

def get_uniqueness_extra_kwargs(self, field_names, declared_fields, extra_kwargs):

    if (getattr(self.Meta, u'validators', None) is not None):
        return (extra_kwargs, {})
    model = getattr(self.Meta, u'model')
    model_fields = self._get_model_fields(field_names, declared_fields, extra_kwargs)
    unique_constraint_names = set()
    for model_field in model_fields.values():
        unique_constraint_names |= {model_field.unique_for_date, model_field.unique_for_month, model_field.unique_for_year}
    unique_constraint_names -= {None}
    for parent_class in ([model] + list(model._meta.parents.keys())):
        for unique_together_list in parent_class._meta.unique_together:
            if set(field_names).issuperset(set(unique_together_list)):
                unique_constraint_names |= set(unique_together_list)
    hidden_fields = {}
    uniqueness_extra_kwargs = {}
    for unique_constraint_name in unique_constraint_names:
        unique_constraint_field = model._meta.get_field(unique_constraint_name)
        if getattr(unique_constraint_field, u'auto_now_add', None):
            default = CreateOnlyDefault(timezone.now)
        elif getattr(unique_constraint_field, u'auto_now', None):
            default = timezone.now
        elif unique_constraint_field.has_default():
            default = unique_constraint_field.default
        else:
            default = empty
        if (unique_constraint_name in model_fields):
            if (default is empty):
                uniqueness_extra_kwargs[unique_constraint_name] = {u'required': True}
            else:
                uniqueness_extra_kwargs[unique_constraint_name] = {u'default': default}
        elif (default is not empty):
            hidden_fields[unique_constraint_name] = HiddenField(default=default)
    for (key, value) in uniqueness_extra_kwargs.items():
        if (key in extra_kwargs):
            value.update(extra_kwargs[key])
        extra_kwargs[key] = value
    return (extra_kwargs, hidden_fields)
