Designed to plug into Pinax easily.
Requires django-tagging
Here is a blog post about how to write reusable django apps with this project as an example.
Installation
Do
svn co http://django-books.googlecode.com/svn/trunk/ books
somewhere on your python path. (/path/to/pinax/projects/complete_project/apps/ for example)
Add to INSTALLED_APPS tuple in settings.py
'books',
Add to urlpatterns in your main urls.py
(r'^books/', include('books.urls')),On a page where you want to add a book to an object add the following code and all you have to do is change my_awesome_object_here to your template variable to attach the book to.
<h2>Books</h2>
{% load book_tags %}
{% books_for_object my_awesome_object_here as books %}
{% for book in books %}
<p><a href="{{ book.get_absolute_url }}">{{ book }}</a> - {{ book.description }}</p>
{% endfor %}
<h2>Add a book</h2>
<form action="{% get_book_form_url my_awesome_object_here %}" method="post">
{% book_form as form %}
{{ form.as_p }}
<input type="submit" value="Go" />
</form>
Pinax Bonus
Here are some examples of Pinax project files that could be altered.
To add books to the listing of things that are tagged, add this to apps/tag_app/views.py in the top includes:
from books.models import Book
in the tags function:
book_tags = TaggedItem.objects.get_by_model(Book, tag).filter(deleted=False)
in the return dictionary:
'book_tags': book_tags,
And add this toward the end of templates/tags/index.html
<h1>{% blocktrans %}All Books Matching <em>{{ tag }}</em>{% endblocktrans %}</h1>
<table class="books">
{% for book in book_tags %}
<p><a href="{% url book_details book.id %}">{{ book.name }}</a></p>
<p>{{ book.description }}</p>
{% endfor %}
</table>