Save the EVEAccount instance before attempting to add characters to it.

Since Django 1.2, the ORM needs to know what database the object belongs in before additions to their M2M fields. Saving the record before the character import solves the problem.
This commit is contained in:
2010-11-04 12:51:11 +00:00
parent 883044348d
commit f64f31deda

View File

@@ -72,14 +72,11 @@ def import_eve_account(api_key, user_id, force_cache=False):
# Create or retrieve the account last to make sure everything
# before here is good to go.
try:
account = EVEAccount.objects.get(id=user_id)
except EVEAccount.DoesNotExist:
account = EVEAccount(id=user_id)
account, created = EVEAccount.objects.get_or_create(id=user_id)
account.api_key = api_key
account.api_user_id = user_id
account.api_status = API_STATUS_OK
account.save()
for node in characters_node_children:
try: