Django template and the locals trick

后端 未结 8 1408
不思量自难忘°
不思量自难忘° 2020-12-02 10:43

The django books gives the local trick in order to avoid to type a long list of parameters as context dictionnary

http://www.djangobook.com/en/2.0/chapter04/

8条回答
  •  温柔的废话
    2020-12-02 11:01

    I've used it without any problems (so far!).

    I'm not especially fond of typing which is why I like it. Code like

    'customer' : customer,
    'invoice' : invoice,
    'date' : date
    

    just looks ridiculous to me and if I can avoid it I will. One of the reasons I like Python is its lack of boilerplate (although this isn't really boilerplate but it is similar).

提交回复
热议问题