【问题标题】:Django: How not to reload the entire page on just a few content updates?Django:如何不通过一些内容更新重新加载整个页面?
【发布时间】:2021-06-16 09:02:35
【问题描述】:

我使用 Django 作为我的 Web 框架。 我想在用户单击按钮时更新页面的内容。 是否可以不更新整个页面?

例如,如果我想编写一个待办事项列表。然后我不想在底部添加项目时重新加载整个页面。

是否有只更新 updatet 元素的解决方案?

不幸的是,在我下面的示例代码中,每次都会重新加载整个页面

def test(request):
    if request.method == 'POST':
        context = {
            'results': 'Some kind of result',
        }
        return render(request, 'users/register.html', context)
    return render(request, 'users/register.html')

【问题讨论】:

  • 您正在搜索术语ajax

标签: python django asynchronous


【解决方案1】:

如果您不想重新加载整个页面,可以使用 Ajax。

【讨论】:

    【解决方案2】:

    是的,您需要为此使用 Ajax。

    现在在所有网站上都可以轻松找到它。

    【讨论】:

      猜你喜欢
      • 2015-02-24
      • 2011-04-08
      • 1970-01-01
      • 1970-01-01
      • 2010-12-04
      • 2018-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多