﻿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
253	Admin add interface is looking for key that doesn't exist	gandalf@…	Adrian Holovaty	"I'm extending tutorial and I've stumbled upon strange behaviour. I added 2 new classes: 'Answer' and 'Exercise'. When I use admin interface to add new 'Exercise' I get following error:

There's been an error:
{{{
Traceback (most recent call last):

  File ""/usr/lib/python2.4/site-packages/django/core/handlers/base.py"", line 63, in get_response
    return callback(request, **param_dict)

  File ""/usr/lib/python2.4/site-packages/django/views/admin/main.py"", line 768, in add_stage
    new_object = manipulator.save(new_data)

  File ""/usr/lib/python2.4/site-packages/django/utils/functional.py"", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))

  File ""/usr/lib/python2.4/site-packages/django/core/meta/__init__.py"", line 1414, in manipulator_save
    obj_list = DotExpandedDict(new_data.data)[rel_opts.object_name.lower()].items()

KeyError: 'answer'

}}}

I am using development web server. New entries to 'Exercise' do get added, despite the error, I can also edit them, add 'answers ' and update them. Clearing database (mysql4) and using `init` and `install` gives the same errors. Also adding new exercises, gives always the samer error.


Here is my code listing:

{{{

gandalf@a1200:/home/stat/webroot/anketa/apps/polls/models$ cat polls.py
from django.core import meta

# Create your models here.

class Poll(meta.Model):
    fields = (
        meta.CharField('question', maxlength=200),
        meta.DateTimeField('pub_date', 'date published'),
    )
    admin = meta.Admin(
        fields = (
                (None, {'fields': ('question',)}),
                        ('Date information', {'fields': ('pub_date',), 'classes': 'collapse'}),
                   ),
        list_display = ('question', 'pub_date', 'was_published_today'),
        list_filter = ['pub_date'],
                 )

    def __repr__(self):
        return self.question
    def was_published_today(self):
        return self.pub_date.date() == datetime.date.today()

class Choice(meta.Model):
    fields = (
        meta.ForeignKey(Poll, edit_inline=True, num_in_admin=3, edit_inline_type=meta.TABULAR),
        meta.CharField('choice', maxlength=200, core=True),
        meta.IntegerField('votes', core=True),
    )
    def __repr__(self):
        return self.choice


class Exercise(meta.Model):
    fields = (
        meta.TextField('question'),
        meta.DateTimeField('pub_date', 'datum naloge'),
        meta.FloatField('order_no', max_digits=2, decimal_places=2),
        )

    admin = meta.Admin()

    def __repr__(self):
        return self.question

class Answer(meta.Model):
    fields = (
        meta.ForeignKey(Exercise, edit_inline=True),
        meta.CharField('answer_desc', maxlength=200, core=True),
        meta.FloatField('entry', max_digits=2, decimal_places=2),
    )

    #admin = meta.Admin()

    def __repr__(self):
        return self.answer_desc

}}}
"	defect	closed	contrib.admin		normal	duplicate			Unreviewed	0	0	0	0	0	0
