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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:58:29+00:00 2026-05-27T12:58:29+00:00

How can I change the default widget for DateField instances in Django ADMIN? I

  • 0

How can I change the default widget for DateField instances in Django ADMIN?

I am aware of how to do this for a ModelForm – How do you change the default widget for all Django date fields in a ModelForm? – by providing formfield_callback that checks the field type and then provides a form field with the new widget.

However, some of my ModelAdmin’s may already have a custom ModelForm, some haven’t. I don’t want to provide/change a ModelForm wherever there’s a date field (that’s the point).

A custom ModelAdmin which could be used for subclassing would be ok, though. How can a ModelAdmin change the date fields of its form, independent of whether a custom ModelForm has been provided or not?

Maybe a ModelAdmin with get_form() calling its super then setting the form’s formfield_callback? Seems a little convoluted, not sure about the timing, and also then there’s three things to be aware of if any ModelAdmin needs further customization…

P.S.: I’m asking this after https://stackoverflow.com/questions/8484811/jquery-datepicker-in-django-admin was erroneously closed for being an “exact duplicate” of the above-mentioned ModelForm question. I hope the difference is now clear.

Btw my personal motivation is the year navigation of django admin’s default datepicker. Really bad for birthdays… 🙂 yes there’s a three-year old ticket https://code.djangoproject.com/ticket/9388

  • 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-27T12:58:30+00:00Added an answer on May 27, 2026 at 12:58 pm

    ModelAdmin can only change the widget of the form it renders, so it would be difficult to override the widgets of a custom form passed to it – at least I can’t think of a clean way to do it.

    I can see a few options for you, depending on how/what you want to customize.

    1. Modify the javascript that does the magic for the widget. This seems easy enough if your change can be handled there. Simply provide your own js/calendar.js and js/admin/DateTimeShortcuts.js the same way you would override the admin’s templates. This has the added bonus of being upgrade friendly; since you are not modifying the django code base; also the change would be immediate for all forms that use the widget.

    2. Customize the built-in django widget to do what you want. This has the benefit of instantly working without any modifications of your existing code, but is not upgrade friendly unless you are careful about patching sources. The source is at django.contrib.admin.widgets

    3. Provide your own custom widget – but then you are back to the problem of going through the code and manually overriding all widget instances with your custom one.

    4. Use something like grappelli and modify the templates/js to do what you want. Added bonus here is that you’ll get lots of other functionality for free (like the ability to have a dashboard, if you plug it in with django-admin-tools).

    django uses jquery extensively in their admin and they have their own jquery namespace (django.jQuery); so if you plan on doing some custom widgets make sure you use the right namespace to avoid strange problems.

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

Sidebar

Related Questions

How can I change default Generate Method Stub behavior in Visaul Studio to generate
Can anyone tell me how can I change the default style of DropDownlist scrollbar
In ASP MVC (RC 1), how can I change the default template for ValidationSummary?
How can I change for example default width and height for buttons, etc?
I can't seems to change the default color of the required field validator. In
How can I change the selection color on a ListView? By default, when the
How can I change ASP.NETAJAX ModalPopupExtender z-index. By default it is 100001. Thanks.
I'd like to change the Default altFormat , but I can't seem to get
What is default hash algorithm that ASP.NET membership uses? And how can I change
For some reason, I can not seem to change the default position of an

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.