Achieving django url-like functionality using resource_name in tastypie
Although I'm not sure that the approach of using the resource_name with slashes will always work for you, in order to resolve your issue you can simply change the order of the URL registration.
When register the urls, register the resource with the name "library/books" last.
The reason that you have the issue is that "library/books/shelf" is caught as the book with the pk of "shelf". If the url patterns of the resource "library/books/shelf" will come first, they will be caught by Django before trying to resolve library/books/pk.
Is there a way to create a hierarchy of resources in tastypie using resource_name that will behave like regular django urls? I'm aiming to have tastypie urls that look like this: <app_name>/<module_name>/<functionality>, but I'm having trouble.
I've created resources with the following resource_name:

library/books
  library/books/shelf
  library/books/circulation

(Note that the parent resource library/book has no trailing slash)
In this case, I can access the parent resource just fine. However, when trying to access one of the children resources (e.g. /api/v1/library/books/circulation) I receive the following error:

Invalid resource lookup data provided (mismatched type).

On the other hand, when I define the parent's resource_name as library/books/ (with a trailing slash), the children resources come back fine - but the parent resource itself returns a 404 error.
All is well if I format the resource_names with underscores (library_books, library_books_circulation) - but then they're really ugly...
I'm running Python 2.7.3, using Django 1.6 with Tastypie 0.10.0.