Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#712 closed defect (duplicate)

trunk django/core/meta/ in method_save(opts, self) raises exceptions.AttributeError (osx, mysql4, python24)

Reported by: levicook@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: blocker Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Interactive Session (ipython)

In [1]: from import ingredients

In [2]: ingredients.get_count()
Out[2]: 0L

In [3]: ingredients.Ingredient??
Type:           ModelBase
Base Class:     <class 'django.core.meta.ModelBase'>
String Form:    <class ''>
Namespace:      Interactive
File:           /Users/levi/Projects/
class Ingredient (meta.Model):
    name = meta.CharField(maxlength=30)
    description = meta.TextField()
    parent_type = meta.ForeignKey('self')

    def __repr__(self):
        return '%s' %

In [4]: i = ingredients.Ingredient()

In [5]: hasattr(i, 'id')
Out[5]: False

In [6]: hasattr(i, 'save')
Out[6]: True

In [7]: = 'Milk'
In [7]:
exceptions.AttributeError                            Traceback (most recent call last)


/Users/levi/Projects/3rdParty/django_src/django/utils/ in _curried(*moreargs, **morekwargs)
      1 def curry(*args, **kwargs):
      2     def _curried(*moreargs, **morekwargs):
----> 3         return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
      4     return _curried

/Users/levi/Projects/3rdParty/django_src/django/core/meta/ in method_save(opts, self)
    782     # First, try an UPDATE. If that doesn't update anything, do an INSERT.
--> 783     pk_val = getattr(self,
    784     pk_set = bool(pk_val)
    785     record_exists = True

AttributeError: 'Ingredient' object has no attribute 'id'

svn info

levi@id ~/Projects/3rdParty/django_src
$ svn info
Path: .
Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
Revision: 1032
Node Kind: directory
Schedule: normal
Last Changed Author: adrian
Last Changed Rev: 1031
Last Changed Date: 2005-10-30 21:17:39 -0600 (Sun, 30 Oct 2005)

uname -a

levi@id ~/Projects/3rdParty/django_src
$ uname -a
Darwin id.local 8.2.0 Darwin Kernel Version 8.2.0: Fri Jun 24 17:46:54 PDT 2005; root:xnu-792.2.4.obj~3/RELEASE_PPC Power Macintosh powerpc

port active

levi@id ~/Projects/3rdParty/django_src
$ port installed 
The following ports are currently installed:
  bash-completion 20050721_0+dp_completion (active)
  bison 2.1_0 (active)
  coreutils 5.2.1_4 (active)
  libiconv 1.10_1+darwin_8 (active)
  lynx 2.8.5rel.2_0 (active)
  mysql4 4.1.14_1+darwin_8 (active)
  openssl 0.9.8a_0+darwin_8 (active)
  postgresql8 8.0.4_1+darwin_8 (active)
  py-ipython 0.6.15_0 (active)
  py-mx 2.0.5_1 (active)
  py-mysql 1.2.0_0 (active)
  py-psycopg 1.1.21_0+darwin_8 (active)
  py-readline 2.4.1_0 (active)
  python24 2.4.1_6 (active)
  readline 5.0.005_0+darwin_8 (active)
  ruby 1.8.2_6
  zlib 1.2.3_0 (active)

Change History (1)

comment:1 Changed 13 years ago by Adrian Holovaty

Resolution: duplicate
Status: newclosed

Duplicate of #662.

Note: See TracTickets for help on using tickets.
Back to Top