[Fixed]-Django model objects, admin and javascript files

1👍

Here are some options:

  • You can show or hide different parts of the page using Django
    templates, no need to use JS for that.
  • Inset JS code declaring those JS variables directly to your Django
    template like:


<script>
var GROUP_OBJECT_CATEGORY = "{{GROUP.OBJECT.CATEGORY}}";
</script>

and use GROUP_OBJECT_CATEGORY global variable in your JS code.

  • Create an endpoint (view) in your Django that will return group object in
    JSON format and check group value of that object in your JS:


$.getJSON( "/api/get_object", function( object ) {
if(object.group && object.group < 2 ){
....
}
});

Leave a comment