一个初学者的辛酸路程-依旧Django
回顾:
- 视图中: 使用reverse函数来做
- 模板种: {% url "a1" %}
- def get(self,request,*args,**kwargs):
- ..
- request.POST.get
- request.GET.get
- request.FILES.get()
- #checkbox复选框
- ......getlist()
- request.path_info
- 文件对象 = request.FILES.get() 或者input的name
- 文件对象.name
- 文件对象.size
- 文件对象.chunks()
- #<form 特殊的设置></form>
- render(request,HTML模板文件的路径,{‘k1’:[1,2,3,4],'k2':{'name':'da','age':73}})
- redirect("URL") 就是我们写的URL,也可以是别的网站
- HttpResponse(字符串)
- render(request,HTML模板文件的路径,{'obj':1234,‘k1’:[1,2,3,4],'k2':{'name':'da','age':73}})
- <h1> {{ obj }}</h1>
- <h1> {{ k1.3 }}</h1>
- <h1> {{ k2.name}}</h1>
- 循环列表
- {% for i in k1 %}
- <p> {{ i}}</p>
- {% endfor%}
- 循环字典
- {% for row in k2.keys %}
- {{ row }}
- {% endfor %}
- {% for row in k2.values %}
- {{ row }}
- {% endfor %}
- {% for k,v in k2.items %}
- {{ k }}--{{v}}
- {% endfor %}
- age = models.IntergerField() 整数不用加长度,没有一点用
- name = models.CharField(max_length=12) 字符长度,只接受12个字符
- 生成数据库结构:
- python manage.py makemigrations
- python manage.py migrate
- 如果没有生成,那就是settings.py里要注册app,不然会出问题,数据库创建不了。
- from django.db import models
- # Create your models here.
- #业务线
- class Business(models.Model):
- #默认有个id列
- caption = models.CharField(max_length=32)
- class Host(models.Model):
- nid = models.AutoField(primary_key=True)
- hostname = models.CharField(max_length=32,db_index=True)
- ip = models.GenericIPAddressField(protocol="ipv4",db_index=True)
- port = models.IntegerField()
- b = models.ForeignKey(to="Business",to_field='id')
- code = models.CharField(max_length=32,null=True,default="SA")
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h1>业务线列表(对象方式)</h1>
- <ul>
- {% for row in v1 %}
- <li>{{ row.id }}-{{ row.caption }}-{{ row.code }}</li>
- {% endfor %}
- </ul>
- <h1>业务线列表(字典)</h1>
- <ul>
- {% for row in v2 %}
- <li>{{ row.id }}-{{ row.caption }}</li>
- {% endfor %}
- </ul>
- <h1>业务线列表(元祖)</h1>
- <ul>
- {% for row in v3 %}
- <li>{{ row.0 }}-{{ row.1 }}</li>
- {% endfor %}
- </ul>
- </body>
- </html>
- from django.shortcuts import render
- from app01 import models
- # Create your views here.
- def business(request):
- v1 = models.Business.objects.all()
- #获取的是querySET,里面放的是对象,1个对象有1行数据,每个对象里有个id caption code
- #[obj(id,caption,code),obj(id,caption,code)]
- v2 = models.Business.objects.all().values('id','caption')
- #querySET ,字典
- #[{'id':1,'caption':'yunwei'},{}]
- v3 = models.Business.objects.all().values_list('id','caption')
- #querySET ,元祖
- #[(1,运维部),(2,开发)]
- return render(request,'business.html',{'v1':v1,'v2':v2,'v3':v3})
- from django.conf.urls import url
- from django.contrib import admin
- from app01 import views
- urlpatterns = [
- url(r'^admin/', admin.site.urls),
- url(r'^business$', views.business),
- ]
- from django.db import models
- # Create your models here.
- #业务线
- class Business(models.Model):
- #默认有个id列
- caption = models.CharField(max_length=32)
- code = models.CharField(max_length=32,null=True,default="SA")
- class Host(models.Model):
- nid = models.AutoField(primary_key=True)
- hostname = models.CharField(max_length=32,db_index=True)
- ip = models.GenericIPAddressField(protocol="ipv4",db_index=True)
- port = models.IntegerField()
- b = models.ForeignKey(to="Business",to_field='id')
- print(row.nid,row.hostname,row.ip,row.port,row.b_id,row.b.caption,row.b.code,row.b.id)
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h1>host表</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>IP</th>
- <th>端口</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v1 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ row.hostname }}</td>
- <td>{{ row.ip }}</td>
- <td>{{ row.port }}</td>
- <td>{{ row.b.caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </body>
- </html>
- def host(request):
- #也有3种方式
- v1 = models.Host.objects.filter(nid__gt=0)
- for row in v1:
- print(row.nid,row.hostname,row.ip,row.port,row.b_id,row.b.caption,row.b.code,row.b.id)
- # return HttpResponse("Host")
- return render(request,'host.html',{'v1':v1})
- from django.conf.urls import url
- from django.contrib import admin
- from app01 import views
- urlpatterns = [
- url(r'^admin/', admin.site.urls),
- url(r'^business$', views.business),
- url(r'^host$', views.host),
- ]
- from django.db import models
- # Create your models here.
- #业务线
- class Business(models.Model):
- #默认有个id列
- caption = models.CharField(max_length=32)
- code = models.CharField(max_length=32,null=True,default="SA")
- class Host(models.Model):
- nid = models.AutoField(primary_key=True)
- hostname = models.CharField(max_length=32,db_index=True)
- ip = models.GenericIPAddressField(protocol="ipv4",db_index=True)
- port = models.IntegerField()
- b = models.ForeignKey(to="Business",to_field='id')
- from django.conf.urls import url
- from django.contrib import admin
- from app01 import views
- urlpatterns = [
- url(r'^admin/', admin.site.urls),
- url(r'^business$', views.business),
- url(r'^host$', views.host),
- ]
- def host(request):
- #也有3种方式
- v1 = models.Host.objects.filter(nid__gt=0)
- # for row in v1:
- # print(row.nid,row.hostname,row.ip,row.port,row.b_id,row.b.caption,row.b.code,row.b.id)
- v2 = models.Host.objects.filter(nid__gt=0).values('nid','hostname','b_id','b__caption')
- # return HttpResponse("Host")
- print(v2)
- v3 = models.Host.objects.filter(nid__gt=0).values_list('nid','hostname','b_id','b__caption')
- # return HttpResponse("Host")
- for row in v2:
- print(row['nid'],row['hostname'],row['b_id'],row['b__caption'])
- return render(request,'host.html',{'v1':v1,'v2':v2,'v3':v3})
- from django.db import models
- # Create your models here.
- # class Foo(models.Model):
- # name = models.CharField(max_length=1)
- #业务线
- class Business(models.Model):
- #默认有个id列
- caption = models.CharField(max_length=32)
- code = models.CharField(max_length=32,null=True,default="SA")
- # fk = models.ForeignKey('Foo')
- class Host(models.Model):
- nid = models.AutoField(primary_key=True)
- hostname = models.CharField(max_length=32,db_index=True)
- ip = models.GenericIPAddressField(protocol="ipv4",db_index=True)
- port = models.IntegerField()
- b = models.ForeignKey(to="Business",to_field='id')
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h1>host表(对象)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>IP</th>
- <th>端口</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v1 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ row.hostname }}</td>
- <td>{{ row.ip }}</td>
- <td>{{ row.port }}</td>
- <td>{{ row.b.caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(字典)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v2 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ row.hostname }}</td>
- <td>{{ row.b__caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(元祖)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v3 %}
- <tr h-id="{{ row.0 }}" bid="{{ row.2 }}">
- <td>{{ row.1 }}</td>
- <td>{{ row.3 }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </body>
- </html>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .hide{
- display: none;
- }
- .shade{
- position: fixed;
- top:0;
- right:0;
- left:0;
- bottom:0;
- background: black;
- opacity:0.6;
- z-index: 100;
- }
- .add-modal{
- position: fixed;
- height:300px;
- width: 400px;
- top: 100px;
- left:50%;
- z-index: 101;
- border:1px solid red;
- background: white;
- margin-left: -200px;
- }
- </style>
- </head>
- <body>
- <h1>host表(对象)</h1>
- <div>
- <input id="add_host" type="button" value="添加" />
- </div>
- <table border="1">
- <thead>
- <tr>
- <th>序号</th>
- <th>主机名</th>
- <th>IP</th>
- <th>端口</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v1 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ forloop.counter }}</td>
- <td>{{ row.hostname }}</td>
- <td>{{ row.ip }}</td>
- <td>{{ row.port }}</td>
- <td>{{ row.b.caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(字典)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v2 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ row.hostname }}</td>
- <td>{{ row.b__caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(元祖)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v3 %}
- <tr h-id="{{ row.0 }}" bid="{{ row.2 }}">
- <td>{{ row.1 }}</td>
- <td>{{ row.3 }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- #遮罩层
- <div class="shade hide"></div>
- #添加层
- <div class="add-modal hide">
- <form method="POST" action="/host">
- <div class="group">
- <input type="text" placeholder="主机名" name="hostname" />
- </div>
- <div class="group">
- <input type="text" placeholder="IP" name="ip" />
- </div>
- <div class="group">
- <input type="text" placeholder="端口 " name="port" />
- </div>
- <div class="group">
- <select name="b_id">
- {% for op in b_list %}
- <option value="{{ op.id }}">{{ op.caption }}</option>
- {% endfor %}
- </select>
- </div>
- <input type="submit" value="提交">
- <input id="cancel" type="button" value="取消">
- </form>
- </div>
- <script src="/static/jquery-1.12.4.js"></script>
- <script>
- $(function(){
- $('#add_host').click(function(){
- $('.shade,.add-modal').removeClass('hide');
- })
- $('#cancel').click(function(){
- $('.shade,.add-modal').addClass('hide');
- })
- })
- </script>
- </body>
- </html>
- def host(request):
- if request.method == 'GET':
- v1 = models.Host.objects.filter(nid__gt=0)
- v2 = models.Host.objects.filter(nid__gt=0).values('nid','hostname','b_id','b__caption')
- v3 = models.Host.objects.filter(nid__gt=0).values_list('nid','hostname','b_id','b__caption')
- b_list = models.Business.objects.all()
- return render(request,'host.html',{'v1':v1,'v2':v2,'v3':v3,'b_list':b_list})
- elif request.method == "POST":
- h = request.POST.get("hostname")
- i = request.POST.get("ip")
- p = request.POST.get("port")
- b = request.POST.get("b_id")
- # models.Host.objects.create(hostname=h,
- # ip=i,
- # port=p,
- # b=models.Business.objects.get(id=b)
- # )
- models.Host.objects.create(hostname=h,
- ip=i,
- port=p,
- b_id=b
- )
- return redirect('/host')
- from django.conf.urls import url
- from django.contrib import admin
- from app01 import views
- urlpatterns = [
- url(r'^admin/', admin.site.urls),
- url(r'^business$', views.business),
- url(r'^host$', views.host),
- ]
- type: "POST",
- data: {'k1':"123",'k2':"root"},
- success: function(data){
- }
- })
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .hide{
- display: none;
- }
- .shade{
- position: fixed;
- top:0;
- right:0;
- left:0;
- bottom:0;
- background: black;
- opacity:0.6;
- z-index: 100;
- }
- .add-modal{
- position: fixed;
- height:300px;
- width: 400px;
- top: 100px;
- left:50%;
- z-index: 101;
- border:1px solid red;
- background: white;
- margin-left: -200px;
- }
- </style>
- </head>
- <body>
- <h1>host表(对象)</h1>
- <div>
- <input id="add_host" type="button" value="添加" />
- </div>
- <table border="1">
- <thead>
- <tr>
- <th>序号</th>
- <th>主机名</th>
- <th>IP</th>
- <th>端口</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v1 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ forloop.counter }}</td>
- <td>{{ row.hostname }}</td>
- <td>{{ row.ip }}</td>
- <td>{{ row.port }}</td>
- <td>{{ row.b.caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(字典)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v2 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ row.hostname }}</td>
- <td>{{ row.b__caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(元祖)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v3 %}
- <tr h-id="{{ row.0 }}" bid="{{ row.2 }}">
- <td>{{ row.1 }}</td>
- <td>{{ row.3 }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- #遮罩层
- <div class="shade hide"></div>
- #添加层
- <div class="add-modal hide">
- <form method="POST" action="/host">
- <div class="group">
- <input id="host" type="text" placeholder="主机名" name="hostname" />
- </div>
- <div class="group">
- <input id="ip" type="text" placeholder="IP" name="ip" />
- </div>
- <div class="group">
- <input id="port" type="text" placeholder="端口 " name="port" />
- </div>
- <div class="group">
- <select id="sel" name="b_id">
- {% for op in b_list %}
- <option value="{{ op.id }}">{{ op.caption }}</option>
- {% endfor %}
- </select>
- </div>
- <input type="submit" value="提交">
- <a id="ajax_submit" style="display: inline-block;padding: 5px;color: white">提交Ajax</a>
- <input id="cancel" type="button" value="取消">
- </form>
- </div>
- <script src="/static/jquery-1.12.4.js"></script>
- <script>
- $(function(){
- $('#add_host').click(function(){
- $('.shade,.add-modal').removeClass('hide');
- });
- $('#cancel').click(function(){
- $('.shade,.add-modal').addClass('hide');
- });
- $('#ajax_submit').click(function(){
- $.ajax({
- url: "/test_ajax",
- type: 'POST',
- data: {'hostname':$('#host').val(),'ip':$('#ip').val(),'port':$('#port').val(),'b_id':$('#sel').val()},
- success: function(data){
- if(data == "OK"){
- location.reload()
- }else{
- alert(data);
- }
- }
- })
- })
- })
- </script>
- </body>
- </html>
- def test_ajax(request):
- # print(request.method,request.POST,sep='\t')
- # import time
- # time.sleep(5)
- h = request.POST.get("hostname")
- i = request.POST.get("ip")
- p = request.POST.get("port")
- b = request.POST.get("b_id")
- if h and len(h) >5:
- models.Host.objects.create(hostname=h,
- ip=i,
- port=p,
- b_id=b
- )
- return HttpResponse('OK')
- else:
- return HttpResponse('太短了')
- from app01 import views
- urlpatterns = [
- url(r'^admin/', admin.site.urls),
- url(r'^business$', views.business),
- url(r'^host$', views.host),
- url(r'^test_ajax$', views.test_ajax),
- ]
- <input type="submit" value="提交">
- <a id="ajax_submit" style="display: inline-block;padding: 5px;background-color: red;color: white">提交Ajax</a>
- <input id="cancel" type="button" value="取消">
- <span id="erro_msg" style="color: red;"></span>
- </form>
- </div>
- <script src="/static/jquery-1.12.4.js"></script>
- <script>
- $(function(){
- $('#add_host').click(function(){
- $('.shade,.add-modal').removeClass('hide');
- });
- $('#cancel').click(function(){
- $('.shade,.add-modal').addClass('hide');
- });
- $('#ajax_submit').click(function(){
- $.ajax({
- url: "/test_ajax",
- type: 'POST',
- data: {'hostname':$('#host').val(),'ip':$('#ip').val(),'port':$('#port').val(),'b_id':$('#sel').val()},
- success: function(data){
- var obj = JSON.parse(data);
- if(obj.status){
- location.reload();
- }else{
- $('#erro_msg').text(obj.error);
- }
- }
- })
- })
- })
- </script>
- def test_ajax(request):
- # print(request.method,request.POST,sep='\t')
- # import time
- # time.sleep(5)
- import json
- ret = {'status': True,'error':None,'data':None}
- try:
- h = request.POST.get("hostname")
- i = request.POST.get("ip")
- p = request.POST.get("port")
- b = request.POST.get("b_id")
- if h and len(h) >5:
- models.Host.objects.create(hostname=h,
- ip=i,
- port=p,
- b_id=b)
- # return HttpResponse('OK')
- else:
- ret['status'] = False
- ret['error'] = "太短了"
- # return HttpResponse('太短了')
- except Exception as e:
- ret['status'] = False
- ret['error'] = "请求错误"
- return HttpResponse(json.dumps(ret))
- data: $('#edit_form').serialize()
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .hide{
- display: none;
- }
- .shade{
- position: fixed;
- top:0;
- right:0;
- left:0;
- bottom:0;
- background: black;
- opacity:0.6;
- z-index: 100;
- }
- .add-modal,.edit-modal{
- position: fixed;
- height:300px;
- width: 400px;
- top: 100px;
- left:50%;
- z-index: 101;
- border:1px solid red;
- background: white;
- margin-left: -200px;
- }
- </style>
- </head>
- <body>
- <h1>host表(对象)</h1>
- <div>
- <input id="add_host" type="button" value="添加" />
- </div>
- <table border="1">
- <thead>
- <tr>
- <th>序号</th>
- <th>主机名</th>
- <th>IP</th>
- <th>端口</th>
- <th>业务线名称</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v1 %}
- <tr hid="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ forloop.counter }}</td>
- <td>{{ row.hostname }}</td>
- <td>{{ row.ip }}</td>
- <td>{{ row.port }}</td>
- <td>{{ row.b.caption }}</td>
- <td>
- <a class="edit">编辑</a>|<a class="delete">删除</a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(字典)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v2 %}
- <tr h-id="{{ row.nid }}" bid="{{ row.b_id }}">
- <td>{{ row.hostname }}</td>
- <td>{{ row.b__caption }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <h1>host表(元祖)</h1>
- <table border="1">
- <thead>
- <tr>
- <th>主机名</th>
- <th>业务线名称</th>
- </tr>
- </thead>
- <tbody>
- {% for row in v3 %}
- <tr h-id="{{ row.0 }}" bid="{{ row.2 }}">
- <td>{{ row.1 }}</td>
- <td>{{ row.3 }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- #遮罩层
- <div class="shade hide"></div>
- #添加层
- <div class="add-modal hide">
- <form id="add_form" method="POST" action="/host">
- <div class="group">
- <input id="host" type="text" placeholder="主机名" name="hostname" />
- </div>
- <div class="group">
- <input id="ip" type="text" placeholder="IP" name="ip" />
- </div>
- <div class="group">
- <input id="port" type="text" placeholder="端口 " name="port" />
- </div>
- <div class="group">
- <select id="sel" name="b_id">
- {% for op in b_list %}
- <option value="{{ op.id }}">{{ op.caption }}</option>
- {% endfor %}
- </select>
- </div>
- <input type="submit" value="提交">
- <a id="ajax_submit" style="display: inline-block;padding: 5px;color: white">提交Ajax</a>
- <input id="cancel" type="button" value="取消">
- <span id="erro_msg" style="color: red;"></span>
- </form>
- </div>
- <div class="edit-modal hide">
- <form id="edit_form" method="POST" action="/host">
- <input type="text" name="nid" style="display: none;">
- <input type="text" placeholder="主机名" name="hostname" />
- <input type="text" placeholder="IP" name="ip" />
- <input type="text" placeholder="端口 " name="port" />
- <select name="b_id">
- {% for op in b_list %}
- <option value="{{ op.id }}">{{ op.caption }}</option>
- {% endfor %}
- </select>
- <a id="ajax_submit_edit">确定编辑</a>
- </form>
- </div>
- <script src="/static/jquery-1.12.4.js"></script>
- <script>
- $(function(){
- $('#add_host').click(function(){
- $('.shade,.add-modal').removeClass('hide');
- });
- $('#cancel').click(function(){
- $('.shade,.add-modal').addClass('hide');
- });
- $('#ajax_submit').click(function(){
- $.ajax({
- url: "/test_ajax",
- type: 'POST',
- {# data: {'hostname':$('#host').val(),'ip':$('#ip').val(),'port':$('#port').val(),'b_id':$('#sel').val()},#}
- data: $('#add_form').serialize(),
- success: function(data){
- var obj = JSON.parse(data);
- if(obj.status){
- location.reload();
- }else{
- $('#erro_msg').text(obj.error);
- }
- }
- })
- })
- $('.edit').click(function(){
- $('.shade,.edit-modal').removeClass('hide');
- var bid = $(this).parent().parent().attr('bid');
- var nid = $(this).parent().parent().attr('hid');
- $('#edit_form').find('select').val(bid);
- $('#edit_form').find('input[name="nid"]').val(nid);
- //修改操作了
- $.ajax({
- data: $('#edit_form').serialize()
- });
- //获取到models.Host.objects.filter(nid=nid).update()
- })
- })
- </script>
- </body>
- </html>
一个初学者的辛酸路程-依旧Django的更多相关文章
- 一个初学者的辛酸路程-继续Django
问题1:HTTP请求过来会先到Django的那个地方? 先到urls.py ,里面写的是对应关系,1个URL对应1个函数名. 如果发URL请求过来,到达这里,然后帮你去执行指定的函数,函数要做哪些事 ...
- 一个初学者的辛酸路程-初识Django
前言: 主要是关于JavaScript的高级部分以及Django 主要内容: 一.jQuery 事件绑定: DOM事件绑定: -直接在标签上绑定 第一种: $('.title').click(func ...
- 一个初学者的辛酸路程-基于Django写BBS项目
前言 基于Django的学习 详情 登录界面 找个模板 http://v3.bootcss.com/examples/signin/ 右键,检查源码 函数 def login(request) ...
- 一个初学者的辛酸路程-python操作SQLAlchemy-13
前言 其实一开始写blog,我是拒绝的,但是,没办法,没有任何理由抗拒.今天呢,要说的就是如何使用Python来操作数据库. SQLAlchemy SQLAlchemy是Python编程语言下的一款O ...
- 一个初学者的辛酸路程-FTP-9
前言 今天,我要描述一个FTP的故事 主要内容 嗯,今天主要以阶梯性的形式来做一个FTP项目. 第一步: 我要实现这么一个功能,一个FTP客户端,1个FTP服务端,2端建立连接以后可以进行通讯. 服务 ...
- 一个初学者的辛酸路程-socket编程-8
前言: 你会发现会网络是多么幸福的事情 主要内容: socket 概念: socket本质上就是2台网络互通的电脑之间,架设一个通道,两台电脑通过这个通道来实现数据的互相传递.我们知道网络通信都是基于 ...
- 一个初学者的辛酸路程-Python基础-3
前言 不要整天沉迷于学习-. 字典 一.我想跟你聊聊字典 1.为何要有字典? 大家有没有想过为什么要有字典?有列表不就可以了吗? 也许大家会这么认为,我给大家举个例子,大家就明白了. 比如说,我通讯录 ...
- 一个初学者的辛酸路程-了解Python-2
前言 blog花了一上午写的,结果笔记本关机了,没有保存,找不到了,找不到了啊,所以说,你看的每一篇blog可能都是我写了2次以上的--.哎!! 代码改变世界,继续......... Python基础 ...
- 一个初学者的辛酸路程-初识Python-1
前言 很喜欢的一句话,与诸位共勉. 人的一切痛苦,本质上都是对自己无能的愤怒----王小波. 初识Python 一.它的爸爸是谁 首先,我们需要认识下面这位人物. 他是Python的创始人,吉多范罗苏 ...
随机推荐
- POJ-3190 Stall Reservations---优先队列+贪心
题目链接: https://vjudge.net/problem/POJ-3190 题目大意: 有N头奶牛,每头奶牛都会在[1,1000000]的时间区间内的子区间进行挤奶.挤奶的时候奶牛一定要单独放 ...
- poj 2115 扩展欧几里得
题目链接:http://poj.org/problem?id=2115 题意: 给出一段循环程序,循环体变量初始值为 a,结束不等于 b ,步长为 c,看要循环多少次,其中运算限制在 k位:死循环输出 ...
- Gym - 100004A 树的性质
题目: 题意: 从节点 0 出发,把每一个节点都经过一遍,然后从一个节点回到学校. 由于有 n+1个节点,n条边,而且保证两两互相到达,那么这就是一个棵树. 于是,可以发现,如果从一个点出发,然后回到 ...
- Zabbix3.0部署实践
Zabbix3.0部署实践 Zabbix3整个web界面做了一个全新的设计. 1.1Zabbix环境准备 [root@linux-node1 ~]# cat /etc/redhat-release ...
- 解决SurfaceView调用setZOrderOnTop(true)遮挡其他控件的问题
SurfaceView遮挡其他控件的项目背景: 最近在做播放器项目,由于底层实现是用Surface和OpenGL切换渲染,所以在布局里面同时使用了GLSurfaceView和SurfaceView,同 ...
- Eclipse Python插件 PyDev
PyDev for Eclipse 是一个功能强大且易用的 Eclipse Python IDE 插件.本文将向读者介绍 PyDev 开源项目及其安装配置方法,并在此基础上详细介绍如何利用 PyDev ...
- iterm2配置项
1. 启动终端Terminal2. 进入当前用户的home目录 输入cd ~3. 创建.bash_profile 输入touch .bash_profile 在导入并应用完颜色方案之后,通 ...
- 带有data-ng-bind表达式
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- Webpack4 学习笔记四 暴露全局变量、externals
前言 此内容是个人学习笔记,以便日后翻阅.非教程,如有错误还请指出 webpack 暴露全局变量 通过 expose-loader 内联配置 在 webpack中配置 每个模块通过注入的方式 通过CD ...
- 简单webservice实现(xFire1.2)
基于xfire实现webservice的实例 首先下载xfire的jar包,并导入项目当中 下载地址:http://xfire.codehaus.org/Download 编写实现类 首先建一个接口把 ...