#10992: Unable to re-save inlines with custom char primary key
---------------------------------------+------------------------------------
Reporter: marcob | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: SVN
Keywords: inline custom primary key | Stage: Unreviewed
Has_patch: 0 |
---------------------------------------+------------------------------------
Define a simple models.py like this one:
{{{
from django.db import models
class Master(models.Model):
codice = models.CharField(
primary_key=True,
max_length=30,
)
class Detail(models.Model):
codice = models.CharField(
primary_key=True,
max_length=30,
)
fk = models.ForeignKey(Master)
}}}
And an admin.py like this one:
{{{
from django.contrib import admin
from models import Master, Detail
class DetailInline(admin.TabularInline):
model = Detail
class MasterAdmin(admin.ModelAdmin):
inlines = [DetailInline,]
admin.site.register(Master, MasterAdmin)
}}}
Create and save a Master record with a Detail inline record.
Reopen the Master record, try to save it again.
Bang!
{{{
AttributeError at /admin/pluto/master/test/
'unicode' object has no attribute 'pk'
Exception Location: C:\work\esempio\lib\django\forms\models.py in
save_existing_objects, line 521
}}}
I fixed it changing line 521:
{{{
try:
pk_value = form.fields[pk_name].clean(raw_pk_value).pk
except AttributeError:
pk_value = form.fields[pk_name].clean(raw_pk_value)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/10992>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---