- if hasattr(book_info, 'parts'):
- for n, part_url in enumerate(book_info.parts):
- base, slug = part_url.rsplit('/', 1)
- try:
- child_book = Book.objects.get(slug=slug)
- child_book.parent = book
- child_book.parent_number = n
- child_book.save()
- except Book.DoesNotExist, e:
- raise Book.DoesNotExist(_('Book with slug = "%s" does not exist.') % slug)
+ for n, child_book in enumerate(children):
+ child_book.parent = book
+ child_book.parent_number = n
+ child_book.save()