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

  • Home
  • SEARCH
  • 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 4056830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:52:35+00:00 2026-05-20T14:52:35+00:00

I have a DateTimeField field in my model. I wanted to display it as

  • 0

I have a DateTimeField field in my model. I wanted to display it as a checkbox widget in the Django admin site. To do this, I created a custom form widget. However, I do not know how to use my custom widget for only this one field.

The Django documentation explains how to use a custom widget for all fields of a certain type:

class StopAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.DateTimeField: {'widget': ApproveStopWidget }
    }

This is not granular enough though. I want to change it for only one field.

  • 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-20T14:52:36+00:00Added an answer on May 20, 2026 at 2:52 pm

    Create a custom ModelForm for your ModelAdmin and add ‘widgets’ to its Meta class, like so:

    class StopAdminForm(forms.ModelForm):
      class Meta:
        model = Stop
        widgets = {
          'field_name': ApproveStopWidget(),
        }
        fields = '__all__'
    
    class StopAdmin(admin.ModelAdmin):
      form = StopAdminForm
    

    Done!

    Documentation for this is sort of non-intuitively placed in the ModelForm docs, without any mention to it given in the admin docs. See: Creating forms from models

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

Sidebar

Related Questions

I have a models.DateTimeField() field in my django model. I am using backbone to
I have a model with a datetime field: class MyModel(models.Model): created = models.DateTimeField(auto_now =
I have a field in my model published_on = models.DateTimeField() on a Django template
I need set field value, not passed to Django Form constructor. I have model
I have model created field configurated as follows: created = models.DateTimeField(auto_now_add=True) In JSON fixtures
I have a custom model fields, that can have 'chain' argument. from django.db import
I have a Django app with a model that contains a field of type
I have model with following field. date = models.DateTimeField(auto_now_add=True) When querying such model i`d
I have something like this in form : class EventForm(ModelForm): reg_due_date = forms.DateTimeField(input_formats=('%d/%m/%Y %H:%M',),
Am using django forms on my app. I have a model Client like this:

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.