On Sat, 2007-02-10 at 03:34 -0500, David Abrahams wrote: > > In my attempt to use > > ForeignKey(Track, null=True) > > When I actually tried to use a null Track value, I got: [...traceback snipped...] > > ProgrammingError at /admin/program/session/15/ > ERROR: invalid input syntax for integer: "" SELECT > "program_session"."id","program_session"."title","program_session"."short_title","program_session"."description","program_session"."start_id","program_session"."track_id","program_session"."duration" > FROM "program_session" INNER JOIN "program_timedivision" AS > "program_session__start" ON "program_session"."start_id" = > "program_session__start"."id" WHERE ("program_session__start"."id" ILIKE '40' > AND "program_session"."track_id" = '') > > My wild guess here is that this happens because track_id is the primary key > and thus expects an integer value; had I made the track name its > primary key it might've worked (?). Anyway, if I want to make that > change at this point, I don't know how to do so without losing my > valuable data. Any help you can offer me would be very much > appreciated.
Can you give a little more information about how you triggered this error? It looks like you are doing something in the admin, but I am using null=True foreign keys through the admin successfully without doing anything special, so it's not totally impossible. It shows up fine in the admin system and the database stores the reference as a NULL (in my case). And I'm using PostgreSQL, too, so it's not a db-specific thing that I can see (although I'm using psycopg1, not psycopg2). If you triggered the problem just by trying to add a record in the admin and leaving the "track" reference field empty, it's going to be a little hard to debug remotely. Try creating a smaller project with a trimmed down model -- doing the standard "remove stuff until it starts working or you are only left with the ForeignKey" process. I can't place what portion of the admin is generating the query you are seeing, so any information you can provide would be useful. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---