I'm getting the following error when adding a new record to a "Notify"
table:

-------------------------------

There's been an error:

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 62, in get_response
    return callback(request, **param_dict)

  File "/usr/lib/python2.4/site-packages/django/views/admin/main.py",
line 770, in add_stage
    new_object = manipulator.save(new_data)

  File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py",
line 1409, in manipulator_save
    new_object.save()

  File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py",
line 756, in method_save
    ','.join(field_names), ','.join(placeholders)), db_values)

  File "/usr/lib/python2.4/site-packages/django/core/db/base.py", line
10, in execute
    result = self.cursor.execute(sql, params)

IntegrityError: ERROR:  null value in column "id" violates not-null
constraint

INSERT INTO notify (id,notify_status,notify_email,notify_subject)
VALUES (NULL,'critical','[EMAIL PROTECTED]','Test critical
subject line')

-----------------------------------------------
Here's my class definition:
-----------------------------------------------

class Notify(meta.Model):
    db_table = 'notify'
    fields = (
        meta.IntegerField('id', primary_key=True),
        meta.CharField('notify_status', maxlength=255,
default='normal', choices=(
            ('normal', 'normal'),
            ('critical', 'critical'),
        )),
        meta.EmailField('notify_email', help_text='Recipient of alerts
for assigned jobs'),
        meta.CharField('notify_subject', maxlength=255,
help_text='Subject of email alert that will be sent in case of error'),
    )
    admin = meta.Admin(
        fields = (
            (None, {'fields': ('notify_status', 'notify_email',
'notify_subject')}),
        ),
        list_display = ('notify_status', 'notify_email',
'notify_subject'),
    )

    def __repr__(self):
        return "%s - %s - %s" % (self.notify_status, self.notify_email,
self.notify_subject)

-----------------------------------------

I don't quite understand why it's inserting NULL for the primary key
field, I thought it was supposed to just leave that alone and allow it
to auto-increment?

Any help appreciated.

Thanks, Tom

Reply via email to