urls.py

urlpatterns = [
url('popup_test1',views.popup_test1),
url('popup_test2',views.popup_test2),
]

views.py

from django.shortcuts import render

def popup_test1(request):
return render(request,'popup_test1.html') def popup_test2(request):
if request.method == 'GET':
return render(request, 'popup_test2.html')
elif request.method == 'POST':
name= request.POST.get('city')
return render(request,'popup_test3.html',{'name':name})
popup_test1.html
callback 是回调函数,在数据处理完之后执行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body> <h1>页面</h1>
<select name="" id="i1">
<option value="">上海</option>
<option value="">北京</option>
</select>
<input type="button" value="添加" onclick="PopFunc()"> <script>
function PopFunc() {
window.open('/popup_test2/','/popup_test2/',"status=1, height:500, width:600, toolbar=0, resizeable=0")
} function callback(name) {
var op = document.createElement('option');
op.innerHTML = name;
op.setAttribute('selected','selected');
document.getElementById('i1').appendChild(op)
}
</script>
</body>
</html>
popup_test2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title> </head>
<body>
<form method="POST">
{% csrf_token %}
<input type="text" name="city" />
<input type="submit" value="提交" />
</form> </body>
</html>
popup_test3.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>正在返回</title> </head> <body> <script>
(function () {
var name = "{{ name }}";
window.opener.callback(name);
window.close();
})()
</script> </body>
</html>
 
 


Django popup示例的更多相关文章

  1. 用pycharm开发django项目示例

    pycharm开发django工程(一)  在pycharm(企业版)中新建Django工程,注意使用虚拟环境 创建成功后,在pycharm显示的工程目录结构如下: 打开pycharm的Termina ...

  2. python Django 文件下载示例

    from django.http import StreamingHttpResponse#文件流 def big_file_download(request): # do something... ...

  3. Django小示例

    创建项目,在命令行中输入:django-admin startproject mysite 则会创建一个名为mysite的项目.项目结构如下: +mysite |--+ugo |          | ...

  4. 新建Django项目示例--图书管理系统

    知识点: Django 1. 安装 1. Django版本 1.11.xx 2. 安装方式 1. 命令行 --> Python环境(双版本,pip的使用) 2. PyCharm安装 2. 创建D ...

  5. Django搭建示例项目实战与避坑细节

    Django 开发项目是很快的,有多快?看完本篇文章,你就知道了. 安装 Django 前提条件:已安装 Python. Django 使用 pip 命令直接就可以安装: pip install dj ...

  6. django搭建示例-ubantu环境

    python3安装--------------------------------------------------------------------------- 最新的django依赖pyth ...

  7. celery Django 简单示例

    一.目录结构 二.创建worker文件夹 __init__.py # -*- coding:utf-8 -*-import osfrom celery import Celery, platforms ...

  8. python的日志模块:logging;django的日志系统;django日志输出时间修改

    Django的log,主要是复用Python标准库中的logging模块,在settings.py中进行配置 源代码 1.__init__.py包含以下类: StreamHandler Formatt ...

  9. 【python】-- Django 分页 、cookie、Session、CSRF

    Django  分页 .cookie.Session.CSRF 一.分页 分页功能在每个网站都是必要的,下面主要介绍两种分页方式: 1.Django内置分页 from django.shortcuts ...

随机推荐

  1. java 中常见的一些错误

    1.NosuchMethodError java 类中找不到该方法! 可能该类所在的同一个包下有一个相同的相同的类,然后那个类中没有我们所要调用的类. 解决方法:若那个类不需要,可以删除class! ...

  2. disk_free_space

    $df = disk_free_space('/')/1024/1024/1024; $df_c = disk_free_space("c:"); $df_d = disk_fre ...

  3. Web终端SSH功能

    http://www.laozuo.org/10703.html------ CentOS安装配置GateOne实现Web终端SSH功能

  4. supervisor control in centos 6/7 python2.6.2.7 3.4

    sudo yum install epel-releasesudo yum install python34 sudo pip install virtualenv yum -y install ep ...

  5. range() 与 np.arange()

    转自:http://blog.csdn.net/lanchunhui/article/details/49493633 range()返回的是range object,而np.nrange()返回的是 ...

  6. 【Git 使用笔记】第四部分:git在公司中的开发流程

    先声明几个变量 仓管A:主分支,只有master分支仓管B:开发分支,只有各个业务开发分支   仓管B fork 于 A 如下图 为了保证 代码的稳定性,只有 仓管B中的某个分支测试完毕并进行了代码r ...

  7. MySQL锁定状态查看相关命令

    1.show processlist; SHOW PROCESSLIST显示哪些线程正在运行.您也可以使用mysqladmin processlist语句得到此信息.如果您有SUPER权限,您可以看到 ...

  8. 25个站长必备的SEO优化工具

    搜索引擎抓取内容模拟器 可以模拟蜘蛛抓取指定网页,包括Text.Link.Keywords及Description信息等.http://www.webconfs.com/search-engine-s ...

  9. LoadRunner-关联报错(解决方法一)

    Action.c(153): Error -35061: No match found for the requested parameter "CorrelationParameter_3 ...

  10. ubuntu环境下快速搭建开发环境

    接触ubuntu已经半年了,虽然游戏啊qq啊在linux下配置稍微麻烦一些,但是作为开发环境,ubuntu真的是好东西,无论是c啊还是php and etc 看到官网上文档开发环境建议wamp,如果是 ...