I'm getting a validation error with django form

I'm facing with a validation form problem.

I have this model:

class Documenti(models.Model):

    descr = models.CharField('descrizione ', max_length=200)

    data = models.DateField('data', blank=True)
    objects = models.Manager()

    class Meta:
        verbose_name = 'Documenti'

this is the form:

class DocForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(DocForm, self).__init__(*args, **kwargs)

    class Meta:
        model = Documenti
        exclude = ['id']
        widgets = {
            'data': forms.DateInput(format=FORMATO_INPUT_DATE, attrs={'type': 'date', 'class': 'stdh-data'}),
            'descr': forms.TextInput(attrs={SIZE: '80'}),

and this is the edit function:

def edit_doc(request, doc_id=None):

    :param request:
    :param doc_id:
    if not (doc_id is None):
        doc_that = get_object_or_404(Documenti.objects.all(), pk=doc_id)
        titolo = ED_DOCUMENTO
        doc_that = Documenti()
        titolo = INS_DOCUMENTO

    form = DocForm(request.POST or None, instance=doc_that)

    redirect_to = Documenti().get_absolute_url() + current_page(request)
    if form.is_valid():  # All validation rules pass

        doc = form.save(commit=False)
        return HttpResponseRedirect(redirect_to)  # Redirect after POST

    from documenti.urls import url_views_lista_doc
    url_after_close = full_url(request, 'doc:%s' % url_views_lista_doc)
    dizio = {FORM: form, TitleScheda: titolo, TAG_url_after_close: url_after_close, }
    return generic_render(request, HTML_generic_edit, dizio)

I always get FALSE when I check form.is_valid().

I tried to get error list with {{ form.non_field_errors }} {{ form.field_errors }} but they seems void.

No idea. many thanks in advance

I solved!

I had a dot in my action form. e.g. form name='x' method='POST' action='.'

I remeved that malefic dot (action='') and TADA!!! it works

don't ask me why!

Back to Top