For my first Django app, I'm trying to write a simple quote collection site (think bash.org), with really simple functionality, just to get my feet wet. I'm using sqlite as my database, since it's the easiest to setup.
Here's my only model right now:
class Quote(models.Model):
text = models.TextField();
upvotes = models.IntegerField(default=0)
downvotes = models.IntegerField(default=0)
active = models.BooleanField(default=False)
date_published = models.DateTimeField(auto_now_add=True)
And a really simple detail template, just to dump the information:
Quote: {{ quote.text }}<br>
Upvotes: {{ quote.upvotes }}<br>
Downvotes: {{ quote.downvotes }}<br>
Published: {{ qoute.date_published|date:"F j, Y, g:i a" }}
When I go to the detail page, everything for the given object is outputted properly, except for the datetime (blank). However, I've checked the database and verified that there is a datetime stored in that object's column, and it shows up fine admin area. Also, when I run the shell from manage.py, here's what I get:
>>> q = Quote.objects.all()[0]
>>> q.date_published
datetime.datetime(2009, 7, 24, 23, 1, 7, 858688)
Also, I'm using the generic view django.views.generic.list_detail.object_detail
to handle the request, but I also tried to use the view below and got the same result.
def detail(Request, id):
q = get_object_or_404(Quote, pk=id)
return render_to_response('quotable/quote_detail.html', {'quote': q})
Am I'm doing something wrong in my attempt to display the date, or is something else going on here?
Thanks.