Dear all,
I'd like to create fixture that has relationship to other object. Let's say
I have a Member object that has foreign key to Country.
class Member(User):
country = models.ForeignKey(Country)
I created the fixtures member.json and define it as such:
[
{
"model": "member.Member",
"pk": 1,
"fields": {
"first_name": "John",
"last_name": "Lennon",
"country": 1
}
}
]
I will receive an error as such:
Problem installing fixture '../portal/apps/member/fixtures/member.json':
Traceback (most recent call last):
File
"/usr/local/lib/python2.6/site-packages/django/core/management/commands/loaddata.py",
line 153, in handle
obj.save()
File
"/usr/local/lib/python2.6/site-packages/django/core/serializers/base.py",
line 163, in save
models.Model.save_base(self.object, raw=True)
File "/usr/local/lib/python2.6/site-packages/django/db/models/base.py",
line 484, in save_base
result = manager._insert(values, return_id=update_pk)
File "/usr/local/lib/python2.6/site-packages/django/db/models/manager.py",
line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "/usr/local/lib/python2.6/site-packages/django/db/models/query.py",
line 1035, in insert_query
return query.execute_sql(return_id)
File
"/usr/local/lib/python2.6/site-packages/django/db/models/sql/subqueries.py",
line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File
"/usr/local/lib/python2.6/site-packages/django/db/models/sql/query.py", line
2282, in execute_sql
cursor.execute(sql, params)
File
"/usr/local/lib/python2.6/site-packages/django/db/backends/mysql/base.py",
line 88, in execute
raise Database.IntegrityError(tuple(e))
IntegrityError: (1048, "Column 'city_id' cannot be null")
---
What am I missing here that is not written in the docs? Thank you very much
for the direction.
Best regards,
--
Join Scrum8.com.
http://scrum8.com/jpartogi/
http://twitter.com/scrum8
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---