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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:23:51+00:00 2026-06-13T17:23:51+00:00

Specifically, I would like to render date widget in a form but I would

  • 0

Specifically, I would like to render date widget in a form but I would like it to ‘be’ HTML5 (so I can just forget about the javascript or whatever and trust Chrome, Opera and Safari to display the datepicker).

No javascript solutions please, I have already found those on the web.

Here is a snippet of my code, but it still puts the type attribute of the forms field thedate as a “text”.

#models.py

class MyModel(models.Model):
    user = models.ForeignKey(User)
    thedate = models.DateField()

#forms.py

class MyModelForm(ModelForm):
    class Meta:
        model = MyModel
        widgets = {
            'thedate': TextInput(attrs={'type': 'date'}),
        }

Can anyone please shed a light?

Thanks in advance.

  • 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-06-13T17:23:52+00:00Added an answer on June 13, 2026 at 5:23 pm

    Using django-html5

    1. Install django-html5: pip install django-html5

    2. In forms.py, import html5.forms.widgets as html5_widgets

    3. Set widgets['thedate'] = html5_widgets.DateInput

    I did not personally test it because I just found out the trick but thanks to you I’m probably going to use it 😀

    Just override input_type

    You can also make your own widget, here’s the idea:

    from django import forms
    
    class Html5DateInput(forms.DateInput):
        input_type = 'date'
    

    Refer to django/forms/widgets.py for details 😉

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

Sidebar

Related Questions

I can render to the screen but I would like to be able to
I would like to better understand my application and specifically its memory footprint. I
I would like to create a simple designer which looks like visual studio. Specifically,
I would like to find a replacement for list.com, specifically the ability to accept
I would like to use XPath 2.0, more specifically the distinct-values function. I downloaded
I'd like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would
I would like to connect to a DB2 database, specifically an iSeries version, using
I would like to extract items from this sample html, more specificly, i would
A good example of when exactly to use interfaces specifically in Java would be
I would ask a question regarding compilers, specifically how they work. I would believe

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.