Received: by 10.224.78.209 with SMTP id m17mr7632033qak.3.1349451257520; Fri, 05 Oct 2012 08:34:17 -0700 (PDT) X-BeenThere: django-users@googlegroups.com Received: by 10.229.171.224 with SMTP id i32ls4922510qcz.8.gmail; Fri, 05 Oct 2012 08:33:07 -0700 (PDT) Received: by 10.224.220.12 with SMTP id hw12mr7624491qab.8.1349451187394; Fri, 05 Oct 2012 08:33:07 -0700 (PDT) Received: by 10.224.220.12 with SMTP id hw12mr7624490qab.8.1349451187382; Fri, 05 Oct 2012 08:33:07 -0700 (PDT) Return-Path: Received: from mail-qa0-f49.google.com (mail-qa0-f49.google.com [209.85.216.49]) by gmr-mx.google.com with ESMTPS id ek33si2182501qcb.0.2012.10.05.08.33.07 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 08:33:07 -0700 (PDT) Received-SPF: pass (google.com: domain of tevans...@googlemail.com designates 209.85.216.49 as permitted sender) client-ip=209.85.216.49; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of tevans...@googlemail.com designates 209.85.216.49 as permitted sender) smtp.mail=tevans...@googlemail.com; dkim=pass header...@googlemail.com Received: by mail-qa0-f49.google.com with SMTP id a17so378940qae.8 for ; Fri, 05 Oct 2012 08:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=bxw1qwMPP10CBnTJ4e79SgH548DMPWXaQf5ztWuFU78=; b=h08R4RT+3jty0LcsmSydLhtQlkW5Xj5q2bJBoWxiDJBSmiLHWM+nbhQrKUeuyQVcwP /GQj/4rgBUAll9h3RkqTHI2xq3gGIUOyaxlIDHStwj3HEpw4VPyXeDbY2v+rhtJm26AJ UNoyDvdX0S2fBAoY9P4L2l+X/Fxz8o0CyUPIUZ0xmf13Hd7AlsAD7XhiYl/t7UsoyzjF eTtnIi+T7yyGov1vnVKB32Flc2Afx7mPt+TIrSSeBBuPKRGQpf6//0ZTDAyp6jGUQmhH BXA5zLgXe8cknduwcBMAeruUgQ/PschrSp8NUuf3eDfVAL7lj16d0wgbBVHJ3X4ZDdwA 5PMg== MIME-Version: 1.0 Received: by 10.49.85.202 with SMTP id j10mr26312812qez.59.1349451187238; Fri, 05 Oct 2012 08:33:07 -0700 (PDT) Received: by 10.49.82.41 with HTTP; Fri, 5 Oct 2012 08:33:07 -0700 (PDT) In-Reply-To: <506EF50C.50...@gmail.com> References: <1caf9be7-a687-4ebf-8ac8-14d6ac1ec...@d16g2000yqb.googlegroups.com> <02739c72-931a-4cf2-a0d6-73d6ccdd6559@googlegroups.com> <506EF50C.50...@gmail.com> Date: Fri, 5 Oct 2012 16:33:07 +0100 Message-ID: Subject: Re: object has no attribute '_state' From: Tom Evans To: django-users@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Oct 5, 2012 at 3:56 PM, Demian Brecht wrot= e: > >>> class QuestionSet(models.Model): >>> title =3D models.CharField(max_length=3D100) >>> description =3D models.TextField() >>> order =3D models.IntegerField() >>> >>> def __init__(self, *args, **kwargs): >>> self.title =3D kwargs.get('title','Default Title') >>> self.description =3D kwargs.get('description', 'DefDescription= ') >>> self.order =3D kwargs.get('order', 0) > > > One thing that looks suspect to me here is that you're not calling __init= __ > on models.Model. > I'm sure the OP from June 2010 will be pleased that his question has been answered so many times=E2=80=A6 Cheers Tom PS: To call the parent class(es) constuctor(s) correctly when using python "new style" classes (ie: all Django classes and classes derived from Django classes), you should use super(ClassName, self).__init__() and not call the base class directly.