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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:21:55+00:00 2026-05-19T13:21:55+00:00

How do you customize the display of a form in Django’s admin based on

  • 0

How do you customize the display of a form in Django’s admin based on a form field’s value? For example, I have a field whose default value is “0”. If the field has been set to a non-zero value, I want to show an additional “Edit” link on the form, which would link to a separate page allowing edit other fields related to a related model. I’ve found how to customize admin’s form template, but I can’t find how to access a form field’s actual value in order to add the if/else statement in the template.

I’ve tried digging through the source code, and I’ve traced my field instance to django.contrib.admin.AdminField.field->django.forms.BoundField but displaying the BoundField’s field and data attribute doesn’t show the value stored in the default form field widget markup. How do I access a specific field’s data value inside a template so I can do something like the following?

{% for fieldset in inline_admin_form %}
    {% for line in fieldset %}
        {% for field in line %}
            {{field.field}} {% if field.field.value != 0 %}<a href="/some/path/to/model/{{field.value}}">Edit</a>{% endif %}
        {% endfor %}
    {% endfor %}
{% endfor %}
  • 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-19T13:21:56+00:00Added an answer on May 19, 2026 at 1:21 pm

    Just did a shell session typing in random variables (ipython ftw) and found this:

    boundfield.data = data
    boundfield.field.initial = initial
    
    {% for field in form %}
       {% if field.data != field.field.initial %}Not Initial{% endif %}
    {% endfor %}
    

    Give it a shot!

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

Sidebar

Related Questions

In Django - Overriding get_form to customize admin forms based on request the problem
I have a Model that's managed by Django Admin. How to I customize the
I have a CRUD form that has a select widget. The options in the
I have a form, one of the fields is a select field, with 5
i have to display customize popup window in telerik grid because i cannot display
I am trying to customize the DispForm.aspx Display form in an announcement list but
I'm trying to customize the Django Admin. models.py ============= class Question(models.Model): poll = models.ForeignKey(Poll)
I am trying to customize Django's comments form. Inside django.contrib.comments.forms I noticed that all
I would like to write a shell extensions to completely customize the display of
What is the simplest way to customize the content display of ComboBoxItem? I would

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.