pythondjangodjango-templatesfrontenddjango-template-filters

default_if_none requires 2 arguments, 1 provided


I used default_if_none as shown below:

<input type="text" name='username' value="{{ value|default_if_none: '' }}">

But, I got the error below:

django.template.exceptions.TemplateSyntaxError: default_if_none requires 2 arguments, 1 provide

So, how can I solve the error?


Solution

  • You have an extra space which causes the error.

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

    should be

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