Error on template render in customer doctype

I was trying to implement the customer doctype in my custom application. for this, I’ve been referring to the ERPNext’s Customer doctype. Now the problem is I’m a not getting buttons for creating “new contact” and “new address” like this :

this is my code :

Now I’m getting some error regarding template render :

Can anyone please help me to get rid of this error ??