handle unknown entities.

This commit is contained in:
j 2014-12-17 19:20:00 +00:00
commit beca371b43
3 changed files with 20 additions and 10 deletions

View file

@ -61,12 +61,8 @@ class Entity(models.Model):
return cls.objects.get(pk=ox.fromAZ(id))
@classmethod
def get_by_name(cls, name, default=None):
qs = cls.objects.filter(name_find__icontains=u'|%s|'%name)
if qs.count():
return qs[0]
else:
return default
def get_by_name(cls, name):
return cls.objects.get(name_find__icontains=u'|%s|'%name)
@classmethod
def get_or_create(model, name):