Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7034531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:11:50+00:00 2026-05-28T01:11:50+00:00

I’m writing a small Django app that displays a few simple values from an

  • 0

I’m writing a small Django app that displays a few simple values from an sqlite3 database. My problem is, although one of the fields is a DateTimeField, I get a unicode value for that field when querying. Here’s the relevant part of the model:

class Totals(models.Model):
    time = models.DateTimeField(primary_key=True, blank=False)
    ..

Now if I for example type Totals.objects.all()[0].time in the Django shell (after importing Totals of course), I get u'2012-01-03 04:02:56.966'. Is this normal behavior perhaps, since I’m using sqlite, or is there something wrong? I’m not sure this is relevant, but I had the models auto-generated since I already had the database I wanted to use. The auto-generation procedure naturally had deducted all field types as text, so I fixed them accordingly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:11:51+00:00Added an answer on May 28, 2026 at 1:11 am

    For what is worth, I’m not getting that behaviour (I just get a datetime.datetime object back) using sqlite and I defined the model exactly in the same way you as you provided in the question.

    My guess is that there was some problem during the auto-generation of the models and they don’t really match the schema in the database. Hence, I’d recommend to verify that the schema that would be generated from those models actually matches.

    In my case, what I see is as follows:

    $ python manage.py sql <appname>
    ...
    CREATE TABLE "<appname>_totals" (
    "time" datetime NOT NULL PRIMARY KEY
    )
    ;
    
    
    $ sqlite3 <database_filename>
    .schema <app_name>_totals
    CREATE TABLE "<app_name>_totals" (
    "time" datetime NOT NULL PRIMARY KEY
    );
    

    Note: I’m also using Ubuntu 11.10 with python 2.7.2 and django 1.3.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.