﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1711	[patch] inline editing uses invalid parent_id field when saving	erichs@…	Adrian Holovaty	"In the following example (taken from the OneToOneField example) when adding a new Restaurant or changing a Restaurant in the Admin
interface with some values in the inline edited Pizza fields, an exception is thrown because rather than using the correct ""id""
of Restaurant (taken from Place) the string representation of Place is used:

{{{
from django.db import models

class Place(models.Model):
    name = models.CharField(maxlength=50)
    address = models.CharField(maxlength=80)
    def __repr__(self):
        return ""%s the place"" % self.name
    class Admin:
        list_display=['name', 'address']
        

class Restaurant(models.Model):
    place = models.OneToOneField(Place)
    serves_hot_dogs = models.BooleanField()
    serves_pizza = models.BooleanField()
    def __repr__(self):
        return ""%s the restaurant"" % self.place.name
    class Admin:
        list_display=['place']

class Pizza(models.Model):
    name = models.CharField(maxlength=50, core=True)
    price = models.IntegerField()
    restaurant = models.ForeignKey(
        Restaurant,
        edit_inline=models.TABULAR,
        num_in_admin=3,
        num_extra_on_change=3,
        )

}}}

That's the exception:
---------------------

{{{
ProgrammingError at /admin/bug1/restaurant/add/
ERROR: syntax error at or near ""Pizza"" at character 86 INSERT INTO ""bug1_pizza"" (""name"",""price"",""restaurant_id"") VALUES ('Pepperoni',12,Fat Pizza the place)
Request Method: 	POST
Request URL: 	http://192.168.1.111:8000/admin/bug1/restaurant/add/
Exception Type: 	ProgrammingError
Exception Value: 	ERROR: syntax error at or near ""Pizza"" at character 86 INSERT INTO ""bug1_pizza"" (""name"",""price"",""restaurant_id"") VALUES ('Pepperoni',12,Fat Pizza the place)
Exception Location: 	.....\django\django\db\backends\util.py in execute, line 11
}}}



A simple workaround is to replace the __repr__ method in Place with:


{{{
    def __repr__(self):
        return ""%s"" % self.id

}}}
"	defect	closed	contrib.admin	magic-removal	normal	worksforme		gary.wilson@…	Unreviewed	1	0	0	0	0	0
