diff --git a/python/web/library/models.py b/python/web/library/models.py index 1b50871..05189e1 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -46,22 +46,15 @@ class Book(models.Model): print '%-15s: %50s' % (field[1], '') def getid(self): - try: + if self.id: return self.id.id - except Id.DoesNotExist: - return None + return None def setid(self,newid): - try: - id = self.id - id.delete() - newid = Id(book=self,id=newid) - newid.save() - - except Id.DoesNotExist: - id=Id(id=newid,book=self) - id.save() -# return Book.get(isbn=self.isbn) + if self.id: + self.id.delete() + newid = Id(book=self,id=newid) + newid.save() def get_authors(self): people = self.persons.all()