Skip to content

Commit

Permalink
Merge pull request #60 from ckirby/issue-55
Browse files Browse the repository at this point in the history
Issue 55 fix
  • Loading branch information
palewire committed Oct 11, 2017
2 parents 80272cf + 025f184 commit 39c4ac0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions postgres_copy/copy_from.py
Expand Up @@ -7,6 +7,8 @@
import sys
import csv
from collections import OrderedDict

from django.core.exceptions import FieldDoesNotExist
from django.db import connections, router
from django.contrib.humanize.templatetags.humanize import intcomma

Expand Down Expand Up @@ -105,8 +107,8 @@ def get_field(self, name):
Returns any fields on the database model matching the provided name.
"""
try:
return [f for f in self.model._meta.fields if name in [f.name, f.attname]][0]
except IndexError:
return self.model._meta.get_field(name)
except FieldDoesNotExist:
return None

def get_headers(self):
Expand Down

0 comments on commit 39c4ac0

Please sign in to comment.