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 307537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:34:03+00:00 2026-05-12T07:34:03+00:00

Greetings, I am trying to implement a TimeField model which only consists of HH:MM

  • 0

Greetings,
I am trying to implement a TimeField model which only consists of HH:MM (ie 16:46) format, I know it is possible to format a regular Python time object but I am lost about how to manage this with Django.

Cheers

  • 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-12T07:34:04+00:00Added an answer on May 12, 2026 at 7:34 am

    DateTime fields will always store also seconds; however, you can easily tell the template to just show the hours and minute, with the time filter:

    {{ value|time:"H:M" }}
    

    where “value” is the variable containing the datetime field.

    Of course, you can also resort to other tricks, like cutting out the seconds from the field while saving; it would require just a small change to the code in the view handling the form, to do something like this:

    if form.is_valid():
      instance = form.save(commit=False)
      instance.nosecs = instance.nosecs.strptime(instance.nosecs.strftime("%H:%M"), "%H:%M")
      instance.save()
    

    (note: this is an ugly and untested code, just to give the idea!)

    Finally, you should note that the admin will still display the seconds in the field.
    It should not be a big concern, though, because admin should be only used by a kind of users that can be instructed not to use that part of the field.
    In case you want to patch also the admin, you can still assign your own widget to the form, and thus having the admin using it. Of course, this would mean a significant additional effort.

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

Sidebar

Related Questions

Greetings, I'm trying to write a program in Python which would print a string
Greetings I am trying to find a way to implement view only user group
greetings, im trying to implement an image rollover on a collection of PictureBox (es)
Greetings, I'm trying to implement my custom TAB control. I'd like it to be
Greetings all, I'm trying to implement middleware (driver) for an embedded device with generic
Greetings, for one of my applications I'm trying to implement an Edit menu. This
Greetings, I'm trying to develop some tests for Mason components which requires running them
Greetings I am a jquery newbie and trying to fix an issue which uses
Greetings, I'm trying to implement a Deque using a circular array that extends when
Greetings I'm trying to get an xml file from a website which requires me

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.