mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Make `Formset.__getitem__ O(1), rather than O(n). If you override __iter__ you now need to also override __getitem__` for consistant behavior. Thanks to Carl and Russ for the review.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16770 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -55,7 +55,7 @@ class BaseFormSet(StrAndUnicode):
|
||||
|
||||
def __getitem__(self, index):
|
||||
"""Returns the form at the given index, based on the rendering order"""
|
||||
return list(self)[index]
|
||||
return self.forms[index]
|
||||
|
||||
def __len__(self):
|
||||
return len(self.forms)
|
||||
|
||||
Reference in New Issue
Block a user