a better way to do ajax in django

后端 未结 4 1595
情歌与酒
情歌与酒 2020-12-25 08:51

The other day I wrote some AJAX for a Django app that i have been working on.

I come from Ruby on Rails, so I haven\'t done much in the way of raw JS.

So bas

4条回答
  •  太阳男子
    2020-12-25 09:33

    No matter what, you're going to need at least two things:

    1. Your javascript code to make the call (you have this)

    2. Server side code to handle the request (this is your view and url-config)

    There is absolutely nothing "hacky" about this.

    The third thing, your template file, is optional - but is generally good practice. You want to separate your markup from the code, for many reasons.

    So I think you've got the right idea. Carry on.

提交回复
热议问题