My models.py:
class Projects(models.Model):
projectName =models.CharField(max_length = 100,unique=True,db_index=True)
projectManager = models.ForeignKey('Users')
class Users(models.Model):
name = models.CharField(max_length = 100,unique=True)
designation = models.CharField(max_length =100 )
team = ListField(models.CharField(max_length =100),null=True)
Теперь я пытаюсь создать объект класса Projects с этим кодом в оболочке:
user_object = Users.objects.get(name="abc")
p = Projects(projectName="xyz",projectManager = user_object)
p.save()
На p.save () это дает мнеошибка:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/base.py", line 543, in save_base
for f in meta.local_fields if not isinstance(f, AutoField)]
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/related.py", line 876, in get_db_prep_save
connection=connection)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/subclassing.py", line 28, in inner
return func(*args, **kwargs)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/__init__.py", line 276, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/subclassing.py", line 53, in inner
return func(*args, **kwargs)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/__init__.py", line 271, in get_db_prep_value
value = self.get_prep_value(value)
File "/home/aprainfo/env/lib/python2.5/site-packages/Django-1.3.1-py2.5.egg/django/db/models/fields/__init__.py", line 479, in get_prep_value
return int(value) ValueError: invalid literal for int() with base 10: '4f1116115fcff377b2000001'
Я не знаю, почему он пытается преобразовать строку в int в последней строке. Я не знаю, как избавиться от этой ошибки?