Hi,
using SVN revision 15440 I get some weird behaviour:
Part of my model looks like this:
---------
from django.contrib.gis.db import models
class Address(models.Model):
uuid = UuidField(primary_key=True)
readable = models.CharField(max_length=200)
geo = models.GeometryField()
def save(self, *args, **kwargs):
self.readable, self.geo = geocode(self.readable)
super(Address, self).save(*args, **kwargs)
class Corporation(models.Model):
uuid = UuidField(primary_key=True)
name = models.CharField(max_length=200)
class Branch(models.Model):
uuid = UuidField(primary_key=True)
address = models.OneToOneField(Address)
corporation = models.ForeignKey(Corporation)
---------
In the admin interface I use
---------
class AddressAdmin(admin.ModelAdmin):
readonly_fields = ('geo',)
admin.site.register(Address, AddressAdmin)
class BranchInline(admin.StackedInline):
model = Branch
fields = ('address',)
class CorporationAdmin(admin.ModelAdmin):
inlines = [BranchInline]
fields = ('name',)
admin.site.register(Corporation, CorporationAdmin)
--------
Now for the weird part:
Add a corporation via admin interface, click save, works as expected.
Open the corporation again, in the inlined branch, add a new address,
click save, works as expected.
Then: open that corporation a third time, no matter what you do (delete
a branch, add another, change anything) clicking save returns this error:
MultiValueDictKeyError at
/admin/base/corporation/2b97beda-6893-426c-8229-ddf001394d36/
"Key 'branches-0-uuid' not found in <QueryDict: {u'name': [u'test3'],
u'branches-2-corporation': [u'2b97beda-6893-426c-8229-ddf001394d36'],
u'branches-__prefix__-corporation':
[u'2b97beda-6893-426c-8229-ddf001394d36'], u'branches-2-address': [u''],
u'branches-TOTAL_FORMS': [u'4'], u'branches-0-address':
[u'9bdb294e-650c-4f44-b9fe-f220b97ee959'], u'branches-3-address': [u''],
u'branches-INITIAL_FORMS': [u'1'], u'branches-__prefix__-address':
[u''], u'_save': [u'Save'], u'branches-0-corporation':
[u'2b97beda-6893-426c-8229-ddf001394d36'], u'branches-1-corporation':
[u'2b97beda-6893-426c-8229-ddf001394d36'], u'csrfmiddlewaretoken':
[u'dc7b4e46b2c5d11cc7c0cff546d5dc3a'], u'branches-3-corporation':
[u'2b97beda-6893-426c-8229-ddf001394d36'], u'slug': [u'test3'],
u'branches-MAX_NUM_FORMS': [u''], u'branches-1-address': [u'']}>"
I'm worried about the mention of branches.uuid -- this shows up
nowherein the generated form (only a select 'branches-0-address' with
the uuids of available addresses).
Playing around with fk_name on the inline admin brought me nothing but
error messages…
This only seems to concern the InlineModelAdmin. When I use seperate
ModelAdmin-s, everything works.
Where should I look for the bug? Might it be my custom UUID-field? (but
it seems to work…)
Cheers,
--
Pascal Germroth
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.