python - Why isn't Django returning a datetime field from the database? -
For my first Django app, I'm trying to write a simple bid collection site (looks bash.org) , Really simple methodology, just to get my legs wet. I am using sqlite as my database because it is the easiest to setup.
Here's my only model:
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)
Really a simple extension template to dump more information:
quote: {{quote.text}} & lt; Br> Upvots: {{quote.upvotes}} & lt; Br> Downwots: {{quote.downvotes}} & lt; Br> Published: {{qoute.date_published | Date: "FJ, Y, G: I"}}
When I go to the extension page, everything is output properly for the given object, (Except blank), I have checked the database and verified that it is stored from time to time in that column of that object and it shows the admin area precisely. Also, when I run a shell from manage.py, here's what I get:
& gt; & Gt; & Gt; Q = Quote.objects.all () [0]> gt; & Gt; & Gt; Q.date_published datetime.datetime (2009, 7, 24, 23, 1, 7, 858688)
In addition, I'm using the generic view django.views. List_detail.object_detail
to handle the generic request, but I also tried to use the footage given below and found the same result.
def details (request, id): q = get_object_or_404 (citation, pk = id) returns render_to_response ('quotable / quote_detail.html', {'quote': q})
Am I doing something wrong in my attempt to display the date, or is there something else going on here?
Thank you.
As noted by Adam Bernier, you quote
Comments
Post a Comment