On Tue, Sep 20, 2011 at 10:38:15AM -0700, mhulse wrote: > Hello, > > The problematic code can be found here: > > <https://gist.github.com/1229708> > > TypeError: > > __init__() got multiple values for keyword argument 'baz' > > I have spent the last couple days trying to figure out how to pass a kwarg > from model to fields/forms (and eventually to a widget). > > TBTH, I have had a heck of a time finding a contemporary example of how to > do this that fits the needs of my project. The docs are definitely detailed, > and the Django source code is helpful, but I have yet to piece this puzzle > together. :( > > Any tips would be greatly appreciated. > > Django (1, 4, 0, 'alpha', 0)
Well, the problem is that your defined fields.TestField.__init__ takes
baz as either a keyword argument, or as the first positional arg. As
with related fields, to pass the verbose name in this case you have to
specify it as a keyword argument as well or specify your custom
argument first and shift all other positional arguments. So, to fix
your issue, choose either of the two following::
foo = TestField(baz='bar', verbose_name=u'Foo field',
max_length=100, help_text='Foo baz bar?')
foo = TestField('bar', u'Foo field', max_length=100,
help_text='Foo baz bar?')
Michal
signature.asc
Description: Digital signature

