From patchwork Fri May 3 22:21:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1095064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44wmp23nJLz9sD4 for ; Sat, 4 May 2019 08:22:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="oPXn0PFJ"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44wmp22t39zDqZP for ; Sat, 4 May 2019 08:22:02 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=199.181.239.166; helo=relay0166.mxlogin.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="oPXn0PFJ"; dkim-atps=neutral Received: from relay0166.mxlogin.com (relay0166.mxlogin.com [199.181.239.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44wmnl2RjJzDqY2 for ; Sat, 4 May 2019 08:21:47 +1000 (AEST) Received: from filter001.mxrelay.co (unknown [94.130.183.33]) by relay0166.mxlogin.com (Postfix) with ESMTP id 3DCE4CC50323; Fri, 3 May 2019 17:21:20 -0500 (CDT) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter001.mxrelay.co (Postfix) with ESMTPS id 0B36E1009F0; Fri, 3 May 2019 22:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=qD6K+7U32kVhQY+BaF+AsOtCTAsvoJ3A/j+XAibxpNM=; b=oPXn0PFJuBsQuORu+Zlg20CQeO /SmR0t143e2EXxHUP1BwRWUgSolOXSFtD3QCdTeC+5Fge8qMN+HhVJx2eb0G7Z6JnI9POs3QVVaHa 7GhZ7wmIydJ+IEsJnx+xiG+bepL6fzUzW3/7+uwVSw6+9HSMaiwy9lsc/8QigEe21YlSv2a1psizg hphmUGKqYlAk1E5OA2OH2e5tSJ1kqDnpQtHrreYpPEQB2LTLFlQ+A1qrBZKBZkaoPWCdWF0JpcKDB m8+TJJtUWCfjHpZ+gL27maRvy9bFPCppSkxugivUO2mcWaIdwEvO80OFo28Dk3xGmyqHIJl7Bavk/ lsLd34Ng==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 1/4] forms: Don't attempt to evaluate State at startup Date: Fri, 3 May 2019 16:21:07 -0600 Message-Id: <20190503222110.562-2-stephen@that.guru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190503222110.562-1-stephen@that.guru> References: <20190503222110.562-1-stephen@that.guru> MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" As was designed, starting the interpreter would cause the State model and its entries to be evaluated. This was an issue if, for example, the model had been modified and you were attempting to apply the migration. Traceback (most recent call last): File "manage.py", line 11, in execute_from_command_line(sys.argv) ... File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 1199, in _set_queryset self.widget.choices = self.choices File "/home/patchwork/patchwork/patchwork/forms.py", line 157, in _get_choices super(OptionalModelChoiceField, self)._get_choices()) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 1143, in __len__ return (len(self.queryset) + (1 if self.field.empty_label is not None else 0)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 232, in __len__ self._fetch_all() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1118, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 53, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 899, in execute_sql raise original_exception django.db.utils.OperationalError: (1054, "Unknown column 'patchwork_state.slug' in 'field list'") Resolve this by moving the evaluation into '__init__', meaning it will only occur when a new form is created. Signed-off-by: Stephen Finucane --- patchwork/forms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patchwork/forms.py b/patchwork/forms.py index 5d4c920a..5690eb01 100644 --- a/patchwork/forms.py +++ b/patchwork/forms.py @@ -165,7 +165,6 @@ class OptionalBooleanField(forms.TypedChoiceField): class MultiplePatchForm(forms.Form): action = 'update' - state = OptionalModelChoiceField(queryset=State.objects.all()) archived = OptionalBooleanField( choices=[('*', 'no change'), ('True', 'Archived'), ('False', 'Unarchived')], @@ -176,6 +175,8 @@ class MultiplePatchForm(forms.Form): super(MultiplePatchForm, self).__init__(*args, **kwargs) self.fields['delegate'] = OptionalModelChoiceField( queryset=_get_delegate_qs(project=project), required=False) + self.fields['state'] = OptionalModelChoiceField( + queryset=State.objects.all()) def save(self, instance, commit=True): opts = instance.__class__._meta