All pastes #19265 Raw Edit

Someone

public text v1 · immutable
#19265 ·published 2005-08-04 03:53 UTC
rendered paste body
django-admin.py sql polls
BEGIN;
CREATE TABLE polls_polls (
    id mediumint(9) unsigned auto_increment NOT NULL PRIMARY KEY,
    question varchar(200) NOT NULL,
    pub_date datetime NOT NULL
);
CREATE TABLE polls_choices (
    id mediumint(9) unsigned auto_increment NOT NULL PRIMARY KEY,
    poll_id integer NOT NULL REFERENCES polls_polls (id),
    choice varchar(200) NOT NULL,
    votes integer NOT NULL
);
COMMIT;

>>> poll = polls.Poll(id=None, question="What's up?", pub_date=datetime.now())
>>> p.save()

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in -toplevel-
    p.save()
  File "C:\Python24\Lib\site-packages\django-1.0.0-py2.4.egg\django\core\meta.py", line 87, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
  File "C:\Python24\Lib\site-packages\django-1.0.0-py2.4.egg\django\core\meta.py", line 735, in method_save
    add = not bool(getattr(self, opts.pk.name))
AttributeError: 'Poll' object has no attribute 'id'