Browse files

[1.2.X] Fixed #13730 -- Removed the hard-coding of the requirement th…

…at ForeignKeys have an index. Thanks to Suor for the report.

Backport of r13452 from trunk.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
freakboy3742 committed Jul 30, 2010
1 parent 3227cc5 commit c61811a8f2679fe0dd9943f228e62756e38fb1dc
Showing with 3 additions and 2 deletions.
  1. +3 −2 django/db/models/fields/
@@ -812,15 +812,16 @@ def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs):
to_field = to_field or ( and to_field = to_field or ( and
kwargs['verbose_name'] = kwargs.get('verbose_name', None) kwargs['verbose_name'] = kwargs.get('verbose_name', None)
if 'db_index' not in kwargs:
kwargs['db_index'] = True
kwargs['rel'] = rel_class(to, to_field, kwargs['rel'] = rel_class(to, to_field,
related_name=kwargs.pop('related_name', None), related_name=kwargs.pop('related_name', None),
limit_choices_to=kwargs.pop('limit_choices_to', None), limit_choices_to=kwargs.pop('limit_choices_to', None),
lookup_overrides=kwargs.pop('lookup_overrides', None), lookup_overrides=kwargs.pop('lookup_overrides', None),
parent_link=kwargs.pop('parent_link', False)) parent_link=kwargs.pop('parent_link', False))
Field.__init__(self, **kwargs) Field.__init__(self, **kwargs)
self.db_index = True
def validate(self, value, model_instance): def validate(self, value, model_instance):
if self.rel.parent_link: if self.rel.parent_link:
return return

0 comments on commit c61811a

Please sign in to comment.