How can I show error in HTML, if ChoiceField do not selected? Similary that has CharField(please fill out this field).
My code here:
flat_Adress = (
("1", "West"), ("2", "East") )
class ForecastField(forms.Form):
flat_Ad = forms.ChoiceField(label='ragion ', choices=flat_Adress)
flat_price = forms.CharField(label='subject')
def index(request):
if request.method == "GET":
form_index = ForecastField(request.GET)
if form_index.is_valid():
adress_f = form_index.cleaned_data['flat_Ad']
price_f = form_index.cleaned_data['flat_price']
html_index = "MyHome/index.html"
context = {.... }
return render(request, html_index, context)
else:
newdf = pd.read_csv(r'...csv')
json_records = newdf.reset_index().to_json(orient='records')
data = json.loads(json_records)
html_index = "MyHome/index.html"
context = {'df_csv': data, 'Index_f': ForecastField(), }
return render(request, html_index, context)