Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove fields from ModelForm
    text
    copied!<p>i have a simple ModelForm:</p> <pre><code>class MyForm(ModelForm): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) del self.fields['name'] </code></pre> <p>As you can see, I try to remove a field from the form's field list (the field definitively exists in the model), but I get an Exception:</p> <pre><code>TemplateSyntaxError at [..] Caught an exception while rendering: "Key 'name' not found in Form" </code></pre> <p>I did not write a custom form, so the template where the error occurs is:</p> <pre><code>/templates/admin/includes/fieldset.html, error at line 4 </code></pre> <p>Any ideas?</p> <p>-- UPDATE --</p> <p>The problem appears only in the admin area.</p> <p>-- UPDATE 2 --</p> <p>Maybe a trace dump gives more info:</p> <pre><code>Original Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/defaulttags.py", line 155, in render nodelist.append(node.render(context)) File "/Library/Python/2.5/site-packages/django/template/defaulttags.py", line 239, in render value = bool_expr.resolve(context, True) File "/Library/Python/2.5/site-packages/django/template/__init__.py", line 546, in resolve obj = self.var.resolve(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py", line 687, in resolve value = self._resolve_lookup(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py", line 722, in _resolve_lookup current = current() File "/Library/Python/2.5/site-packages/django/contrib/admin/helpers.py", line 81, in errors return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields]).strip('\n')) File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 105, in __getitem__ raise KeyError('Key %r not found in Form' % name) KeyError: "Key 'name' not found in Form" </code></pre> <p>In the admin area, I use the Grapelli-Theme. Maybe this has to do with the problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload