TypeError: save_file() got an unexpected keyword argument 'save'

294 views
Skip to first unread message

Baurzhan Ismagulov

unread,
May 10, 2007, 5:46:42 PM5/10/07
to django...@googlegroups.com
Hello,

I've upgraded r3709 to 0.96 and started getting the following error:

Traceback (most recent call last):

File "/var/lib/python-support/python2.4/django/core/handlers/base.py", line 77, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/var/lib/python-support/python2.4/django/contrib/admin/views/decorators.py", line 55, in _checklogin
return view_func(request, *args, **kwargs)

File "/var/lib/python-support/python2.4/django/views/decorators/cache.py", line 39, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

File "/var/lib/python-support/python2.4/django/contrib/admin/views/main.py", line 254, in add_stage
new_object = manipulator.save(new_data)

File "/var/lib/python-support/python2.4/django/db/models/manipulators.py", line 105, in save
f.save_file(new_data, new_object, self.change and self.original_object or None, self.change, rel=False, save=False)

TypeError: save_file() got an unexpected keyword argument 'save'

This happens when I try to save a new record to a table using the admin
interface. I've looked at django/db/models/fields/__init__.py, the
method does seem to have the save kwarg. What is the problem?

Thanks in advance,
--
Baurzhan Ismagulov
http://www.kz-easy.com/

Malcolm Tredinnick

unread,
May 10, 2007, 9:58:00 PM5/10/07
to django...@googlegroups.com

Sounds like your code is somehow inconsistent. The "save" parameter was
added when ticket #639 was fixed (a little bit before 0.96 was
released).

There is a chance that some old *.pyc files from the pre-update version
are getting in the way in your source tree (it shouldn't be happening,
but it might be the case). Might depend on how you did the upgrade. Try
removing old *.pyc files.

Other than that, I don't really have any idea why you would be seeing
this problem on a standard Django install. The code certainly seems to
work and I haven't had any problems with it. So there is something
"special" about your installation. That's not much help, except to
encourage you to look closely at what might be unique about your
particular setup.

Regards,
Malcolm

derek

unread,
May 19, 2007, 2:02:45 PM5/19/07
to Django users
i also am seeing this error:

TypeError at /do.upload_photo


save_file() got an unexpected keyword argument 'save'

Request Method: POST
Request URL: http://local.allurstuff.com:8000/do.upload_photo
Exception Type: TypeError
Exception Value: save_file() got an unexpected keyword argument
'save'
Exception Location: /usr/lib/python2.5/site-packages/django/db/models/
manipulators.py in save, line 105

my problem can't be outdated .pyc files, as i have just rebuilt this
machine and this is a fresh django 0.96 install. can you tell me what
i can do to help debug this problem?

thanks,
derek


On May 10, 8:58 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Malcolm Tredinnick

unread,
May 19, 2007, 2:26:38 PM5/19/07
to django...@googlegroups.com
On Sat, 2007-05-19 at 11:02 -0700, derek wrote:
> i also am seeing this error:
>
> TypeError at /do.upload_photo
> save_file() got an unexpected keyword argument 'save'
> Request Method: POST
> Request URL: http://local.allurstuff.com:8000/do.upload_photo
> Exception Type: TypeError
> Exception Value: save_file() got an unexpected keyword argument
> 'save'
> Exception Location: /usr/lib/python2.5/site-packages/django/db/models/
> manipulators.py in save, line 105
>
> my problem can't be outdated .pyc files, as i have just rebuilt this
> machine and this is a fresh django 0.96 install. can you tell me what
> i can do to help debug this problem?

I guess I'd start by putting some debugging prints into
django/db/models/manipulators.py.

If you have a look at the line that is failing, you can see the if-test
just above it that checks that "f" is a FileField instance. If you
haven't installed any third-party apps that would add extra FileField
sub-classes (one thing to check), "f" should be either a FileField or an
ImageField, both of which are defined in
django/db/models/fields/__init__.py (and both of whose save_file()
methods have a "save" argument).

So let's check that "f" really is what we think it is. What is
f.__class__.__name__ at the point of the error?

We can also look at what the arguments are that save_fail() thinks it
should be getting. Again, edit just prior to line 105 to insert
something like the following:

import inspect, sys
print >> sys.stderr, inspect.getargspec(f.save_file)
print >> sys.stderr, inspect.getsourcefile(f.__class__)

Maybe some of the output there will give you or us some more clues about
where the problem could lie.

Regards,
Malcolm


derek

unread,
May 19, 2007, 3:31:30 PM5/19/07
to Django users
fixed it. i was using the custom image uploader available here:
http://code.djangoproject.com/wiki/CustomUploadAndFilters
i simply added "save=True" to the def and the super call, and it works
fine. (updated the code on the wiki too)

thanks,
derek


On May 19, 1:26 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Reply all
Reply to author
Forward
0 new messages