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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:44:26+00:00 2026-05-18T19:44:26+00:00

I have a custom TagField form field. class TagField(forms.CharField): def __init__(self, *args, **kwargs): super(TagField,

  • 0

I have a custom TagField form field.

class TagField(forms.CharField):
    def __init__(self, *args, **kwargs):
        super(TagField, self).__init__(*args, **kwargs)
        self.widget = forms.TextInput(attrs={'class':'tag_field'})

As seen above, it uses a TextInput form field widget. But in admin I would like it to be displayed using Textarea widget. For this, there is formfield_overrides hook but it does not work for this case.

The admin declaration is:

class ProductAdmin(admin.ModelAdmin):
    ...
    formfield_overrides = {
        TagField: {'widget': admin.widgets.AdminTextareaWidget},
    }

This has no effect on the form field widget and tags are still rendered with a TextInput widget.

Any help is much appreciated.

—
omat

  • 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-18T19:44:27+00:00Added an answer on May 18, 2026 at 7:44 pm

    The django admin uses custom widgets for many of its fields. The way to override fields is to create a Form for use with the ModelAdmin object.

    # forms.py
    
    from django import forms
    from django.contrib import admin
    
    class ProductAdminForm(forms.ModelForm):
        def __init__(self, *args, **kwargs):
            super(ProductAdminForm, self).__init__(*args, **kwargs)
            self.fields['tags'].widget = admin.widgets.AdminTextareaWidget()
    

    Then, in your ModelAdmin object, you specify the form:

    from django.contrib import admin
    from models import Product
    from forms import ProductAdminForm
    
    class ProductAdmin(admin.ModelAdmin):
        form = ProductAdminForm
    
    admin.site.register(Product, ProductAdmin)
    

    You can also override the queryset at this time: to filter objects according to another field in the model, for instance (since limit_choices_to cannot handle this)

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

Sidebar

Related Questions

I have custom textfield widget and many form in my project. To use this
I have custom exceptions in my django project that look like this: class CustomFooError(Exception):
I have a custom field name front_sl_slider. I want to display all the posts
I have custom class that implement IEnumerable<int[]> interface and save current Enumerator . When
I have custom Question objects which I render into html form elements. I want
I have custom CSS for checkbox control into my web form, which is linked
I have custom class that extends WebViewPage that I use as the base for
I have custom control - using Win Forms, that contains four TextBoxes, all have
I have custom ImageView: public class ShadowedImageView extends ImageView { private Paint mPaint; public
I have custom type name Netsgroup which is a collection of Net class. Net

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.