Hi! I'm doing my 1st steps in Python/Django using Python Web Development with Django book (http://withdjango.com/)
Chapter 2 is 'developing' simple blog app and here is the model:
From django.db import models
From django.contrib import admin
# Create your models here.
class BlogPost(models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
timestamp = models.DateTimeField()
class Meta:
ordering = ('-timestamp',)
class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')
admin.site.register(BlogPost, BlogPostAdmin)
Now, at one point I was not clear where to add:
class Meta:
ordering = ('-timestamp',)
in order to have descending order of 'blog posts' and was asking on
#django where I got the answer to put it as follows:
[..]
class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')
ordering = ('-timestamp',)
which did not work.
Finally, I managed to add 'class Meta' as subclass of BlogPost class (as
above), but I wonder if adding 'ordering = ('-timestamp',)' to
BlogPostAdmin class is supposed to work or what is explanation if it
should not work (as we experienced)?
Sincerely,
Gour
--
Gour | Zagreb, Croatia | GPG key: C6E7162D
----------------------------------------------------------------
pgpviZmXpg7CY.pgp
Description: PGP signature

