On Tue, Sep 20, 2011 at 04:18:28PM -0700, Micky Hulse wrote: > Optimally, I think I would prefer to keep the verbose name in the > first position (as an arg, not kwarg) in order to keep things > consistent. > > If you look at fields.py: > > <https://gist.github.com/1229708#file_fields.py> > > Line #s 13 and 16, I do this: > > def __init__(self, *args, **kwargs): > self._baz = kwargs.get('baz', None) > > But when I do that, I get this error: > > File "/.../test/fields.py", line 19, in __init__ > TypeError: __init__() got an unexpected keyword argument 'baz'
In this case, the problem is a little bit different. models.CharField.__init__ knows nothing about any 'baz' keyword argument. With your current code, however, you keep the 'baz' item in the kwargs dictionary and also pass this argument to CharField.__init__. That's the cause of this error. The remedy is simple, instead of kwargs.get use kwargs.pop. Michal
signature.asc
Description: Digital signature