i’m trying to use a default value
class MSeguimientoEtnicoForm(forms.ModelForm):
...
fecha_reporte = forms.DateTimeField(widget=forms.DateTimeInput(attrs={'class': 'form-control'}))
...
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Establece la fecha y hora actuales como valor inicial para fecha_reporte
self.fields['fecha_reporte'].initial = timezone.now()
template:
<div class="col-sm-4">
<div class="form-group">
<label for="fechaReporte">Fecha Reporte: </label>
<input class="form-control" id="fechaReporte" type="datetime-local" name="fecha_reporte" required>
</div>
</div>
but doesn’t take the timezone.now() value at the view template
view and default value don’t working
i was searching for aroud but i didn’t found nothing
New contributor
YELLY16 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.