klipstein/dojango — Issue #46: 46 - Django raises TypeError when creating model form with widgets defined in metaclass 
Author: klipstein
Created: 2011-11-06 12:59:16+00:00
State: open

What steps will reproduce the problem?

Just try this code:

from django.db import models
class Pop(models.Model):
name = models.CharField()

from dojango.forms import ModelForm
from dojango.forms import TextInput
class PopForm(ModelForm):
class Meta:
model = Pop
widgets = {
'name' : TextInput,
}

What is the expected output? What do you see instead?

Error when calling the metaclass bases
formfield_function() got an unexpected keyword argument 'widget'
Exception Location:
/srv/foo/trunk/external-packages/django/forms/models.py in
fields_for_model, line 182

What version of the product are you using? On what operating system?

Python Version:	2.6.4
Django Version:	1.2 beta 1
Dojango Version: (0, 5, 0, 'alpha', 0)
Ubuntu karmic.

Please provide any additional information below.
Replacing "from dojango.forms import ModelForm" with "from django.forms
import ModelForm" fixes the problem - there is no TypeError exception.

Original link: http://code.google.com/p/dojango/issues/detail?id=46