﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1010	rev 1560 fails to save object	anonymous	Adrian Holovaty	"Development server revision 1560.
  After updating from I don't know which revision, A model that has the following fields:
     ForeignKey
     IntegerField
     CharField
 When I create a new object for the model do a save() on the object, get this:

------------------------
     Traceback (most recent call last):
  File ""do_ldap.py"", line 361, in ?
    Main()
  File ""do_ldap.py"", line 358, in Main
    add_update_grouptable(server_id='xxx')
  File ""do_ldap.py"", line 328, in add_update_grouptable
    add_g.save()
  File ""/apps/django/lib/django/utils/functional.py"", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
  File ""/apps/django/lib/django/core/meta/__init__.py"", line 1012, in method_save
    db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.attname), True)) for f in opts.fields if not isinstance(f, AutoField)]
  File ""/apps/django/lib/django/core/meta/fields.py"", line 725, in get_db_prep_save
    return int(value)
ValueError: invalid literal for int(): xxx

--------------------------------------
From the source code in fields.py:

    def get_db_prep_save(self,value):
        if value == '' or value == None:
           return None
        else:
           return int(value)

------------
The above if a method from the ForeignKey field, I did pass the foreign key object to when creating the object. Please can this be fixed asap.

"	defect	closed	Core (Other)	dev	critical	duplicate	Revision 1560		Unreviewed	0	0	0	0	0	0
