I need to put a input type date and i'm using a widget but throws this error
models.py
class Proyecto(models.Model):
    nombre = models.CharField(max_length=255)
    fecha_de_inicio = models.DateField()
    fecha_de_termino = models.DateField(blank=True, null=True)
forms.py
from django import forms
from .models import Proyecto
from django.forms.fields import DateField
class ProyectoForm(forms.ModelForm):
    def save(self, usuario=None):
        self.instance.encargado = usuario
        super(ProyectoForm,self).save()
    class Meta:
        model = Proyecto
        fields = ('nombre', 'fecha_de_inicio', 'costo', 'objetivo', 'descripcion', 'cliente', 'estado')
        widgets = {
            'fecha_de_inicio': DateField(),
        }
                There is a problem in setting up the widgets. You cannot set the widget of a field to a form field:
widgets = {'fecha_de_inicio': DateField()}
Instead of a Datefield, you need to provide a widget, e.g. DateInput:
widgets = {'fecha_de_inicio': forms.DateInput(format='%d/%m/%Y')}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With