[Fixed]-Default_if_none requires 2 arguments, 1 provided

48👍

You have an extra space which causes the error.

value="{{ value|default_if_none: '' }}"

should be

value="{{ value|default_if_none:'' }}"

0👍

With Django template filters, putting space either before or after : gets error as shown below:

                            # Space (Error)
                               ↓ ↓
value="{{ value|default_if_none : '' }}"

So, don’t put any space there not to get error as shown below:

                         # No space (No error)
                              ↓ ↓
value="{{ value|default_if_none:'' }}"

In addition, putting space either before or after | doesn’t get error:

            # Space (No error)
               ↓ ↓
value="{{ value | default_if_none:'' }}"

Leave a comment