From 97743cfe168789090342c815c6f571b7025a5f6b Mon Sep 17 00:00:00 2001 From: Adarnof Date: Sun, 13 Nov 2016 16:51:15 -0500 Subject: [PATCH] Prevent admin error when EveCharacter has no assigned user. --- eveonline/admin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eveonline/admin.py b/eveonline/admin.py index 5586c875..5ef4ffd3 100644 --- a/eveonline/admin.py +++ b/eveonline/admin.py @@ -22,12 +22,13 @@ class EveCharacterAdmin(admin.ModelAdmin): @staticmethod def main_character(obj): - auth = AuthServicesInfo.objects.get_or_create(user=obj.user)[0] - if auth and auth.main_char_id: - try: - return EveCharacter.objects.get(character_id=auth.main_char_id) - except EveCharacter.DoesNotExist: - pass + if obj.user: + auth = AuthServicesInfo.objects.get_or_create(user=obj.user)[0] + if auth and auth.main_char_id: + try: + return EveCharacter.objects.get(character_id=auth.main_char_id) + except EveCharacter.DoesNotExist: + pass return None