[Django]-Django modelform property hidden field

5👍

Well I am in the next step of the problem, but i have success in generating true form fields. In place of:

if self.instance:
    self.fields['total_budgeted'] = self.instance.total_budgeted()

You can write:

if self.instance:
    self.fields['total_budgeted'] = form.CharField(
        initial=self.instance.total_budgeted(),
        widget=HiddenInput()
    )

In this code you I instantiate the form Field as CharField, you can use the FormField you want, and I hide it by choosing the Hidden input widget.

👤hisie

Leave a comment