Skip to content

Instantly share code, notes, and snippets.

@howiworkdaily
Created January 23, 2009 21:58
Show Gist options
  • Select an option

  • Save howiworkdaily/51221 to your computer and use it in GitHub Desktop.

Select an option

Save howiworkdaily/51221 to your computer and use it in GitHub Desktop.

Revisions

  1. howiworkdaily created this gist Jan 23, 2009.
    17 changes: 17 additions & 0 deletions Django Admin Required Field Highlight
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    /*

    * Simple code snippet to apply a "* denotes required field" below the Django Admin page title, ex "Change [Model]"

    * It also appends a "[field name]*" to all fields that are required.

    * And finally it makes all the labels for required fields nice a red.

    ** Note: make sure to reference jquery in templates/admin/base_site.html <script type="text/javascript" src="{{ STATIC_URL }}js/jquery-latest.pack.js"></script>

    */

    $(document).ready(function() {
    $('.required').not( $('.inline-related').find('.required') ).append('*').attr("style","color: #FF0000 !important");
    $('.change-form > #container > #content > h1').after('<p style="color:#FF0000 !important"><br/>* denotes required fields.</p>');
    });