I have simple view in django app, which I want to show only when one of the forms is valid. I have something like:
@login_required
@require_role('admin')
def new_package(request):
invoicing_data_form = InvoicingDataForm(instance=request.user.account.company.invoicingdata)
if invoicing_data_form.is_valid():
# all here
return HttpResponse('Form valid')
else:
logger.info("Form invalid")
return HttpResponse(json.dumps(invoicing_data_form.errors)
I always get log info message that form is invalid, however, I get nothing in
invoicing_data_form.errors
It is very strange, because I am validating this form in other view using user input data and it works just fine. Any idea?
EDIT: Just for clarification. I am not requesting any data from user in this form. I am using this form to validate some model instance (this form is subclassing from ModelForm).