Django:popup弹出框简单应用实例

本文介绍如何在Django中实现弹出框功能。通过点击p1.html页面的按钮,弹出p2.html的弹出框,用户在弹框内输入数据,然后在popup_response.html页面处理这些数据。主要涉及视图函数的编写和前端页面的设计。
摘要由CSDN通过智能技术生成

效果:在p1.html页面点击,弹出p2的弹出框,填写数据,在 popup_response页面处理数据

1、视图函数:views.py

from django.shortcuts import render

def p1(request):
    return render(request,"p1.html")

def p2(request):
    if request.method == "GET":
        return render(request,"p2.html")
    elif request.method == "POST":
        city =request.POST.get("city")
        print(city)
        return render(request,"popup_response.html",{
  "city":city}

2、前端页面及函数

p1.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值