Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default_if_none requires 2 arguments, 1 provided

Tags:

django

I tried to use default_if_none in username

   <input type="text" class="form-control" id="username" value="{{ form.username.value|default_if_none: '' }}" name='username'>

It throw error

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

I did not encounter such an error before.

The documentation did not provide a hint to solve the problem.

like image 714
AbstProcDo Avatar asked Jun 26 '18 01:06

AbstProcDo


1 Answers

You have an extra space which causes the error.

value="{{ form.username.value|default_if_none: '' }}"

should be

value="{{ form.username.value|default_if_none:'' }}"
like image 73
scharette Avatar answered Oct 17 '22 22:10

scharette