Code

Opened 7 years ago

Closed 7 years ago

#5144 closed (invalid)

"got an unexpected keyword argument 'max_length'"

Reported by: mikeh@… Owned by: adrian
Component: Contrib apps Version: master
Severity: Keywords: admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mtredinnick)

I'm using revision 5878 to start a new project. I have this in my model:

    first_name=models.CharField(max_length=100)
    last_name=models.CharField(max_length=50)

And I have django.contrib.admin enabled. When I use the Admin App to add a new object of that class, I get the following error::

Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  55. return view_func(request, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in add_stage
  250. manipulator = model.AddManipulator()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/manipulators.py" in __init__
  71. self.fields.extend(f.get_manipulator_fields(self.opts, self, self.change))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/fields/__init__.py" in get_manipulator_fields
  317. return [man(field_name=field_names[i], **params) for i, man in enumerate(field_objs)]
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/utils/maxlength.py" in inner
  48. func(self, *args, **kwargs)

  TypeError at /admin/members/people/add/
  __init__() got an unexpected keyword argument 'max_length'

If I comment out lines 46-67 in django/utils/maxlength.py and change my CharFields records to "maxlength" I can add a object but not view it. But changing that file seems wrong.

Attachments (0)

Change History (6)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

At the top of every documentation page:
"These docs are for Django's SVN release, which can be significantly different than previous releases. Get old docs here: 0.96, 0.95."

comment:2 Changed 7 years ago by mtredinnick

  • Description modified (diff)
  • Resolution invalid deleted
  • Status changed from closed to reopened

Chris, revision 5878 is the current subversion code.

comment:3 Changed 7 years ago by SmileyChris

Gosh, sorry about that Mike H. I'm too pre-SVN trigger happy

comment:4 Changed 7 years ago by mikeh@…

No prob. I was confused by "maxlength" vs "max_length" myself in the docs.

comment:5 Changed 7 years ago by Ramiro Morales

I can't reproduce this on a Debian Etch / Python 2.4.4 / sqlite3 3.3.8. I tested with both r5883 (current trunk tip) and r5878. The models.py file I used is:

# vim: fenc=utf-8 :

from django.db import models

# Create your models here.

class People(models.Model):
    """People model for ticket 5144"""
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=50)

    class Admin:
        pass

    def __unicode__(self):
        return u'%s %s' % (first_name, last_name)

# EOF

comment:6 Changed 7 years ago by mikeh@…

  • Resolution set to invalid
  • Status changed from reopened to closed

I just grabbed rev 5887 and I get the same thing. I tried your example and it works.

I looked at my code again and then at the docs, and noted that EmailFields doesn't accept max_length. Oops.

I'm marking this as invalid. Sorry about wasting your time!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.