Setup:

Ubuntu 9.04
Python 2.6.2
Django 1.0.2
Postgres 8.3.7
postgresql-psycopg2

I'm having issues using ./manage.py syncdb and ./manage.py flush with a
project of mine.  I've got an app, venues, which defines a
ManyToManyField.

After syncdb loads the fixtures, (and only if it tries to load fixtures)
it hits the following error:

{{{
[...]
Installing json fixture 'initial_data' from
'/cgi/django/apps/cdla_apps/venues/fixtures'.
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File
"/var/lib/python-support/python2.6/django/core/management/__init__.py",
line 340, in execute_manager
    utility.execute()
  File
"/var/lib/python-support/python2.6/django/core/management/__init__.py",
line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/var/lib/python-support/python2.6/django/core/management/base.py", line
192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File
"/var/lib/python-support/python2.6/django/core/management/base.py", line
219, in execute
    output = self.handle(*args, **options)
  File
"/var/lib/python-support/python2.6/django/core/management/base.py", line
348, in handle
    return self.handle_noargs(**options)
  File
"/var/lib/python-support/python2.6/django/core/management/commands/syncdb.py", 
line 152, in handle_noargs
    call_command('loaddata', 'initial_data', verbosity=verbosity)
  File
"/var/lib/python-support/python2.6/django/core/management/__init__.py",
line 158, in call_command
    return klass.execute(*args, **options)
  File
"/var/lib/python-support/python2.6/django/core/management/base.py", line
219, in execute
    output = self.handle(*args, **options)
  File
"/var/lib/python-support/python2.6/django/core/management/commands/loaddata.py",
 line 161, in handle
    cursor.execute(line)
  File "/var/lib/python-support/python2.6/django/db/backends/util.py",
line 19, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "id" does not exist
LINE 1: ...LECT setval('"venue_member_id_seq"', coalesce(max("id"),
1),...
}}}

The problem seems to be that VenueMember names its pk "id", but gives it
a db_column='venue_member_id' argument, as follows:

{{{
class VenueMember(_Model):
    id = models.AutoField(db_column='venue_member_id', primary_key=True)
    venue = models.ForeignKey(Venue)
    member = models.ForeignKey(Member)
    role = models.ForeignKey(Role, null=True, blank=True)
    dates = models.ManyToManyField(Date, blank=True, null=True)
}}}

This model is referenced in my Venue model in a
ManyToManyField(through='VenueMember'):

{{{
class Venue(_Model):
    # [... snip fields ...]
    member_set = models.ManyToManyField('Member',
                                        through='VenueMember',
                                        blank=True)

}}}

When the database gets created, it creates a sequence named
'venue_member_venue_member_id_seq' on a column named 'venue_member_id',
but syncdb wants to access it via 'venue_member_id_seq', using the
column name 'id'.  

./manage.py flush yields the following similar error:

{{{
Error: Database docsouth_gtts couldn't be flushed. Possible reasons:
      * The database isn't running or isn't configured correctly.
      * At least one of the expected database tables doesn't exist.
      * The SQL was invalid.
    Hint: Look at the output of 'django-admin.py sqlflush'. That's the
SQL this command wasn't able to run.
    The full error: relation "venue_member_id_seq" does not exist
}}}

Am I doing something wrong, or should I report a bug?  

Cheers,
Cliff



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to