Message from discussion
For QuerySet qs, list(qs)[k] does not always equal qs[k]
Received: by 10.229.97.196 with SMTP id m4mr1067946qcn.9.1240585555377;
Fri, 24 Apr 2009 08:05:55 -0700 (PDT)
Return-Path: <jacob.kaplanm...@gmail.com>
Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.24])
by gmr-mx.google.com with ESMTP id 20si81445qyk.11.2009.04.24.08.05.54;
Fri, 24 Apr 2009 08:05:54 -0700 (PDT)
Received-SPF: pass (google.com: domain of jacob.kaplanm...@gmail.com designates 74.125.92.24 as permitted sender) client-ip=74.125.92.24;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jacob.kaplanm...@gmail.com designates 74.125.92.24 as permitted sender) smtp.mail=jacob.kaplanm...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by qw-out-2122.google.com with SMTP id 8so881929qwh.33
for <django-developers@googlegroups.com>; Fri, 24 Apr 2009 08:05:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:mime-version:received:in-reply-to:references
:from:date:message-id:subject:to:content-type
:content-transfer-encoding;
bh=5NgDaWq2Kfb6/pdGED3OPE8H1D33BFZvb8SuCrwNii0=;
b=qQxGxcLaO8P9aChOPz9w8b9p4DWlBDKhkFnnzUoWGxfZy+ounCvl3YkiVdEEo9WGdk
zJfrb4IzBPTBwXbreO0vmonGbyVxgDLKTvv45ydREGYFMruEfuTJXFPH91U3TFOjNr33
5Co4WMks8Cha/L7iMVmgdaOurhfmvJtxczLwA=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type:content-transfer-encoding;
b=i7HbKM3kiCQFSEazP47DgzGlTRABDDyPe99m3fG3uKQ7t94jTxSROoeQbUJyK5ipxb
8vv8MZUOVlEL/SqZFTigaj5Us7Of5HYR76gjvRXK8dN16otdLeWhr10e3JEN7qF8B6EU
bq9LzYFTbCrdVacD9ORoeXo4cTEBtynPvvDLg=
MIME-Version: 1.0
Received: by 10.220.84.20 with SMTP id h20mr4973052vcl.60.1240585554257; Fri,
24 Apr 2009 08:05:54 -0700 (PDT)
In-Reply-To: <6e5cb63e-f934-4122-8cec-829d45a17b81@3g2000yqk.googlegroups.com>
References: <6e5cb63e-f934-4122-8cec-829d45a17b81@3g2000yqk.googlegroups.com>
From: Jacob Kaplan-Moss <jacob.kaplanm...@gmail.com>
Date: Fri, 24 Apr 2009 10:05:39 -0500
Message-ID: <be4ebbe10904240805p4fe4bab6yc0a827153f78f...@mail.gmail.com>
Subject: Re: For QuerySet qs, list(qs)[k] does not always equal qs[k]
To: django-developers@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Fri, Apr 24, 2009 at 9:09 AM, David Gouldin <dgoul...@gmail.com> wrote:
> Lest you criticize accessing all queryset items by index, Django is
> currently doing just that in
> django.forms.models.BaseModelFormSet._construct_form. =A0This means that
> when creating an inline for a model without an order_by, Django can
> (and has for me) paired forms in the inline formset with the wrong
> model instance!
I actually fixed that yesterday: http://code.djangoproject.com/changeset/10=
625
1.1 now includes a ``QuerySet.ordered`` property which FormSet uses to
artificially apply ordering, if needed. You can -- and should -- do
the same.
Jacob