Commits

Silas Baronda  committed 6aea20f

* Brought django version up to 1.0
* Fixed it so that when we have no books it displays we have no books in the database.

  • Participants
  • Parent commits 6c66b65

Comments (0)

Files changed (5)

File books/admin.py

+from django.contrib import admin
+from library.books.models import Tag, Book
+
+admin.site.register(Book)
+
+class TagAdmin(admin.ModelAdmin):
+  prepopulated_fields = {"slug": ("name", )}
+admin.site.register(Tag, TagAdmin)

File books/models.py

 
 class Tag(models.Model):
     name = models.CharField(max_length=50)
-    slug = models.SlugField(prepopulate_from=('name',))
+    slug = models.SlugField()
     def __unicode__(self):
         return u"%s" % self.name
     class Admin:

File register/__init__.pyc

Binary file modified.

File templates/book/book_list.html

 <h2>Books we have in the system</h2>
+
+{% if object_list %}
+
 <table>
 <tr>
 <td>Book Title</td>
 </tr>
 {% endfor %}
 </table>
+ 
+{% else %}
+
+<p>No books in the system</p>
+
+{% endif %}
 from django.conf.urls.defaults import *
+from django.contrib import admin
 from library.books.models import Book
 
 info_dict = {
     'queryset':  Book.objects.all(),
 }
+admin.autodiscover()
 
 urlpatterns = patterns('',
-    (r'^admin/', include('django.contrib.admin.urls')),
+    (r'^admin/(.*)', admin.site.root),
     (r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'index.html'}),
     (r'^save_text/.*', 'library.books.views.save_text'),
     (r'^get_book/.*', 'library.books.views.get_book'),