loaddata issue

18 views
Skip to first unread message

Mark Jarecki

unread,
May 4, 2007, 1:23:20 AM5/4/07
to django...@googlegroups.com
Hi,

I've come across an issue trying to loaddata into my database, and am wondering if anyone else has come across this too? and how to go about fixing it.

I have Apache2.2.4, mod_python3.3.1, Python-2.5.1, postgresql-8.2.4, psycopg2-2.0.5.1 installed.

Please let me know if you require any more information.

This is the process i followed:

./manage.py dumpdata --format=json Guide > guide.json

[Clear database]

./manage.py syncdb
./manage.py loaddata guide.json

The following is the error I receive:

Loading 'guide' fixtures...
Installing json fixture 'guide' from absolute path.
Installed 140 object(s) from 1 fixture(s)
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/opt/python/lib/python2.5/site-packages/django/core/management.py", line 1674, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/opt/python/lib/python2.5/site-packages/django/core/management.py", line 1588, in execute_from_command_line
    action_mapping[action](args[1:], int(options.verbosity))
  File "/opt/python/lib/python2.5/site-packages/django/core/management.py", line 1418, in load_data
    cursor.execute(line)
  File "/opt/python/lib/python2.5/site-packages/django/db/backends/util.py", line 12, in execute
    return self.cursor.execute(sql, params)
  File "/opt/python/lib/python2.5/site-packages/django/db/backends/postgresql/base.py", line 44, in execute
    return self.cursor.execute(sql, [smart_basestring(p, self.charset) for p in params])
psycopg.ProgrammingError: ERROR:  relation "guide_venuetype_id_seq" does not exist

SELECT setval('Guide_venuetype_id_seq', (SELECT max("id") FROM "Guide_venuetype"));

Thanks in advance,

Mark.

Russell Keith-Magee

unread,
May 4, 2007, 2:46:08 AM5/4/07
to django...@googlegroups.com
On 5/4/07, Mark Jarecki <mjar...@bigpond.net.au> wrote:
>
> Hi,
>
> I've come across an issue trying to loaddata into my database, and am
> wondering if anyone else has come across this too? and how to go about
> fixing it.
>
> I have Apache2.2.4, mod_python3.3.1, Python-2.5.1, postgresql-8.2.4,
> psycopg2-2.0.5.1 installed.
>
> Please let me know if you require any more information.

Django version? :-)

> The following is the error I receive:

...


> psycopg.ProgrammingError: ERROR: relation "guide_venuetype_id_seq" does not
> exist
>
> SELECT setval('Guide_venuetype_id_seq', (SELECT max("id")
> FROM "Guide_venuetype"));

The problem here is that the sequence providing data for the
guide.venuetype table hasn't been created. The only reason I can think
that this wouldn't exist is if you are using a custom primary key on
your guide.venuetype table. Is this the case?

Failing that, can you provide the models.py for the app that causes
this problem (or preferably a cut down minimalist version that
exhibits the problem)?

Yours,
Russ Magee %-)

Mark Jarecki

unread,
May 4, 2007, 3:42:36 AM5/4/07
to django...@googlegroups.com
Running the latest django vesion, just ran svn.

Cut down models:

class VenueType(models.Model):
venueTypeName = models.CharField(maxlength=200, db_index=True)
venueTypeSlug = models.SlugField(prepopulate_from=
('venueTypeName',), db_index=True)
class Admin:
pass

class Venue(models.Model):
venueSlug = models.SlugField(prepopulate_from=('venueName',),
unique=True, db_index=True)
venueType = models.ManyToManyField(VenueType,
filter_interface=models.HORIZONTAL)

Error:

Loading 'test' fixtures...
Installing json fixture 'test' from absolute path.
Installed 1 object(s) from 1 fixture(s)


Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/opt/python/lib/python2.5/site-packages/django/core/
management.py", line 1674, in execute_manager
execute_from_command_line(action_mapping, argv)
File "/opt/python/lib/python2.5/site-packages/django/core/
management.py", line 1588, in execute_from_command_line
action_mapping[action](args[1:], int(options.verbosity))
File "/opt/python/lib/python2.5/site-packages/django/core/
management.py", line 1418, in load_data
cursor.execute(line)
File "/opt/python/lib/python2.5/site-packages/django/db/backends/
util.py", line 12, in execute
return self.cursor.execute(sql, params)
File "/opt/python/lib/python2.5/site-packages/django/db/backends/
postgresql/base.py", line 44, in execute
return self.cursor.execute(sql, [smart_basestring(p,
self.charset) for p in params])

psycopg.ProgrammingError: ERROR: relation "guide_venuetype_id_seq"
does not exist

SELECT setval('Guide_venuetype_id_seq', (SELECT max("id") FROM
"Guide_venuetype"));

Hope this helps.

Thanks again,

Mark

Russell Keith-Magee

unread,
May 4, 2007, 8:10:54 AM5/4/07
to django...@googlegroups.com
On 5/4/07, Mark Jarecki <mjar...@bigpond.net.au> wrote:
>
> Running the latest django vesion, just ran svn.
>
> Cut down models:
..

I loaded some same venuetype data using the admin interface, dropped
the db, recreated it, synced and loaded the data; it worked fine for
me (Postgres 8.1 on OSX, psycopg1 backend)

To try and track this further, can you provide:
- A copy of a minimal data file that failes
- A transcript of the output of ./manage.py sqlall guide (a listing of
the sql executed to create the models in the first place)

Yours,
Russ Magee %-)

Mark Jarecki

unread,
May 5, 2007, 12:37:33 AM5/5/07
to django...@googlegroups.com

Hi Russ,

Here is the transcript of the output:

./manage.py sqlall Guide

BEGIN;

CREATE TABLE "Guide_venuetype" (

"id" serial NOT NULL PRIMARY KEY,

"venueTypeName" varchar(200) NOT NULL,

"venueTypeSlug" varchar(50) NOT NULL

);

CREATE TABLE "Guide_venue" (

"id" serial NOT NULL PRIMARY KEY,

"venueName" varchar(200) NOT NULL,

"venueSlug" varchar(50) NOT NULL UNIQUE

);

CREATE TABLE "Guide_venue_venueType" (

"id" serial NOT NULL PRIMARY KEY,

"venue_id" integer NOT NULL REFERENCES "Guide_venue" ("id") DEFERRABLE INITIALLY DEFERRED,

"venuetype_id" integer NOT NULL REFERENCES "Guide_venuetype" ("id") DEFERRABLE INITIALLY DEFERRED,

UNIQUE ("venue_id", "venuetype_id")

);

CREATE INDEX "Guide_venuetype_venueTypeName" ON "Guide_venuetype" ("venueTypeName");

CREATE INDEX "Guide_venuetype_venueTypeSlug" ON "Guide_venuetype" ("venueTypeSlug");

CREATE INDEX "Guide_venue_venueName" ON "Guide_venue" ("venueName");

CREATE UNIQUE INDEX "Guide_venue_venueSlug" ON "Guide_venue" ("venueSlug");

COMMIT;

and here is the minimal data file that fails:

cat test.json

[{"pk": "1", "model": "Guide.venuetype", "fields": {"venueTypeSlug": "stadium", "venueTypeName": "Stadium"}}]

Regards,

Mark

Russell Keith-Magee

unread,
May 5, 2007, 8:21:18 PM5/5/07
to django...@googlegroups.com
On 5/5/07, Mark Jarecki <mjar...@bigpond.net.au> wrote:
>
>
> Hi Russ,
>
> Here is the transcript of the output:
>
> ./manage.py sqlall Guide

Ok - found it. The problem is the capitalization on the application
name. For some reason, django isn't taking the lower case version of
the application name when specifying the database table in sequence
reset code.

As a sort term solution, if you rename the application `Guide` to
`guide`, the problem will go away. If you could open a ticket for this
issue, I'd be much obliged; i'll try to work up a permanent fix.

Apologies for the inconvenience here, and thanks for the helpful debugging data.

Yours,
Russ Magee %-)

Mark Jarecki

unread,
May 6, 2007, 7:11:06 PM5/6/07
to django...@googlegroups.com
Hi Russ,

Thank you for all your help, I renamed my app name and it works fine
at the moment.

I posted a ticket (I hope its ok, my fist one) #4231.

Thanks again,

Mark.

Russell Keith-Magee

unread,
May 12, 2007, 11:23:57 AM5/12/07
to django...@googlegroups.com
On 5/7/07, Mark Jarecki <mjar...@bigpond.net.au> wrote:
>
> Hi Russ,
>
> Thank you for all your help, I renamed my app name and it works fine
> at the moment.
>
> I posted a ticket (I hope its ok, my fist one) #4231.

Ticket description was fantastic.

FYI, I've fixed the problem in [5204]. The problem was some missing
quotes in the generated SQL. The sequence name wasn't getting quoted
in the sequence reset statement, so the capitalized application name
was causing Postgres some grief.

Thanks for the helpful report.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages