I had been using Shelfari for a few years to keep track of books I've read and plan to read. I really liked the website's interface and they had this nice widget that lets you display a bookshelf of your reading list on your blog. But when I forced SSL on my blog, it stopped working. The widget doesn't work over https.
I then looked for other widgets and tried Amazon's widget. But their widget looked ugly and ad blocker plugins block it. So I decided to just write my own.
At first, I thought about making this very simple. Just one simple model for a Book and display its attributes in a template. But I will have to manually enter the books one by one, which will be very tedious. I decided to spend a little bit more time on it and use Amazon's Product Advertising API, which will let me search Amazon's database and pull the book attributes that I need.
I've actually used their API before for another project, EZ Price Alerts, so I was able to reuse existing code with very little modification (basically just limiting the search to Books and pulling a few additional attributes).
The setup is quite simple:
- A 'Book' model to store book information.
- A ListView to display the list of books with pagination.
- A TemplateView to display search results from Amazon.
- An Ajax view for creating/updating books.
- An Ajax view for deleting books from the list.
- A template tag to return the book object by ASIN (used in the search result template so I can mark books I've already added).
To interact with the Amazon API, I used a Python wrapper called bottlenose as it makes it a lot easier.
For the UI, I pretty much tried to copy Shelfari's as I liked theirs. Used Bootstrap and a little bit of jQuery to make the Ajax calls. I also limited access to some of the views using django-braces.
I'm pretty happy with how it turned out, I might even create a separate app and open source the code for it in the future just for fun.
Click here to see the list of my favorite books.