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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:00:12+00:00 2026-05-18T11:00:12+00:00

I have a model with a boolean value like that: class TagCat(models.Model): by_admin =

  • 0

I have a model with a boolean value like that:

class TagCat(models.Model):
    by_admin = models.BooleanField(default=True) 

This appears as a checkbox in admin.

  1. How could I use this as a radio button in admin?
  2. Also, how do I make it be always with a certain selected value in admin?
  3. Also, I want the default value to be the opposite, when a non-admin user adds a TagCat. This field should be hidden from him.

Can someone tell me how to do this? Django documentation doesn’t seem to go in such details.

  • 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-18T11:00:13+00:00Added an answer on May 18, 2026 at 11:00 am

    UPDATE 1: Code that gets me done with 1) (don’t forget tot pass CHOICES to the BooleanField in the model)

    from main.models import TagCat
    from django.contrib import admin
    from django import forms
    
    class MyTagCatAdminForm(forms.ModelForm):
        class Meta:
            model = TagCat
            widgets = {
                'by_admin': forms.RadioSelect
            }
            fields = '__all__' # required for Django 3.x
        
    class TagCatAdmin(admin.ModelAdmin):
        form = MyTagCatAdminForm
    
    
    admin.site.register(TagCat, TagCatAdmin)
    

    The radio buttons appear ugly and displaced, but at least, they work

    1. I solved with following info in MyModel.py:
    BYADMIN_CHOICES = (
        (1, "Yes"),
        (0, "No"),
    )
    
    class TagCat(models.Model):
        by_admin = models.BooleanField(choices=BYADMIN_CHOICES,default=1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery function tied to my submit button like this: $(function ()
I have used the get_or_create function on my models in Django. This function returns
This seems like it should be prettty easy - but I just can't get
I have (or so I think!) a simple problem. I will greatly simplify my
I realy appreciate Spring 3 anoation driven mapping of Web Controllers I have a
Will this query work? Is it most efficient? SELECT * FROM `posts` WHERE MATCH
I'm new in C# but not new to coding --being doing it for almost
I am new to Spring MVC and I'm in the process of learning how
The Problem I am using dynamic matrix groups as in Dynamic Grouping from Chris

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.