[Answered ]-Pass database value in form (django)

2👍

Even if I don’t quite get the intention of your form, but for the sake of answering your question, you could pass the initial value from your views when you initialize the form, this will make the value flexible:

def your_view(request):
    # get the string for affilizione by applying your logic here
    # initial_value = 'red'
    form = BannerForm(request.POST or None, initial={'Affiliazione': initial_value})

Leave a comment