__init__() got an unexpected keyword argument 'max_digits'

1,156 views
Skip to first unread message

adamjspooner

unread,
Jun 28, 2007, 3:06:59 PM6/28/07
to Django users
Hello all,

I'm adding a DecimalField to a preexisting app:

foo_bar = models.DecimalField(max_digits=5, decimal_places=2,
blank=True, null=True, default=0.0, unique=True)

I've added a row in the table:

foo_bar DECIMAL(5,2) UNI NULL;

But when I try to syncdb or even validate the app I get:

my_site.foo_bar: __init__() got an unexpected keyword argument
'max_digits'

I reversed all changes and still get the error.

Any help is greatly appreciated!
Adam

Malcolm Tredinnick

unread,
Jun 28, 2007, 9:48:45 PM6/28/07
to django...@googlegroups.com

Is the error really coming from the line you indicate? You should see
the same problem if you run "manage.py shell" and import that model.
What does the full traceback say in the latter case?

Reading the error messsage, it looks like you've left a FloatField in
the code somewhere that still has the max_digits parameter being passed
to its constructor (FloatField fields no longer take max_digits or
decimal_places arguments).

The only other thing I can think of is that somehow your source code is
corrupted. Have a look in django/db/models/fields/__init__.py where the
DecimalField class is defined. The __init__ method should look like
this:

def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs):

You can see that "max_digits" is certainly allowed there.

Regards,
Malcolm

--
On the other hand, you have different fingers.
http://www.pointy-stick.com/blog/

Reply all
Reply to author
Forward
0 new messages