I think that line should be
job = metaForeignKey(Job, null=True)
The _id is implied - it's part of the machinery that links your Log to
your Job. Semantically, your log is linked to a job, not a jobid.
On 8/26/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Seems like my ForeignKeys aren't working any more. This is my model
> (abbreviated):
>
> -----------------------------------
>
> class Log(meta.Model):
> id = meta.AutoField(primary_key=True)
> jobid = meta.ForeignKey(Job, null=True)
> status = meta.CharField(maxlength=1, default='U')
> timestamp = meta.DateTimeField(auto_now_add=True)
> log = meta.TextField()
> uid = meta.CharField(maxlength=255)
> class META:
> db_table = 'log'
> ordering = ['-timestamp']
>
> ------------------------------------
>
> But when I try to run a simple get_list() against this I get this...
>
> ------------------------------------
>
> >>> from django.models.jobmonitor import logs
> >>> logs.get_list()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> 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 1120, in function_get_list
> return list(function_get_iterator(opts, klass, **kwargs))
> File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py",
> line 1103, in function_get_iterator
> cursor.execute("SELECT " + (kwargs.get('distinct') and "DISTINCT "
> or "") + ",".join(select) + sql, params)
> File "/usr/lib/python2.4/site-packages/django/core/db/base.py", line
> 10, in execute
> result = self.cursor.execute(sql, params)
> psycopg.ProgrammingError: ERROR: column log.jobid_id does not exist
>
> SELECT log.id,log.jobid_id,log.status,log.timestamp,log.log,log.uid
> FROM log ORDER BY log.timestamp DESC
>
> -----------------------------------
>
> Any ideas where I'm going wrong? I'm not sure why it's appending "_id"
> onto my fieldname for log.jobid here...
>
> Thanks, Tom
>
>