I have a simple test model defined:
class Friend(models.Model):
name = models.CharField(max_length=120)
class Person(models.Model):
name = models.CharField(max_length=120)
friend = models.OneToOneField(Friend)
Here is a sample of usage, and obviously I am doing something wrong...
>>> p = mymodels.Person()
>>> p.name="John Smith"
>>> f = mymodels.Friend()
>>> f.name = "John Q. Smith"
>>> p.friend = f
>>> p.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\python26\lib\site-packages\django\db\models\base.py", line
311, in save
self.save_base(force_insert=force_insert, force_update=force_update)
File "C:\python26\lib\site-packages\django\db\models\base.py", line
383, in save_base
result = manager._insert(values, return_id=update_pk)
File "C:\python26\lib\site-packages\django\db\models\manager.py",
line 138, in _insert
return insert_query(self.model, values, **kwargs)
File "C:\python26\lib\site-packages\django\db\models\query.py", line
894, in insert_query
return query.execute_sql(return_id)
File "C:\python26\lib\site-packages\django\db\models\sql\subqueries.py",
line 309, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File "C:\python26\lib\site-packages\django\db\models\sql\query.py",
line 1734, in execute_sql
cursor.execute(sql, params)
File "C:\python26\lib\site-packages\django\db\backends\util.py",
line 19, in execute
return self.cursor.execute(sql, params)
File "C:\python26\lib\site-packages\django\db\backends\sqlite3\base.py", line
168, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: polls_person.friend_id may not be NULL
So then I try the following:
>>> p.friend.save()
>>> p.save()
And get the same error?
Any help would be appreciated.
Sincerely,
Dudley
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---