[Fixed]-How to dynamically apply css to django include


Let’s say you import this in your index.html file, and the corresponding view is index, if you are sending a class_name value in your context then you can use that value in your included template.

def index(request):
    return render_to_response('index.html', {'class_name': 'value'})

You included .html file is part of index.html so you can use the same variables there.

Here you will find documentation to write views and pass context (variables) to template. And if you are using Class-based views you will find docs here.


Leave a comment