当前位置: 首页 > news >正文

steam网站代做商品推广软文写作500字

steam网站代做,商品推广软文写作500字,电脑上买wordpress,wordpress桌面客户端django学习笔记 http://djangobook.py3k.cn/2.0/chapter05/ 文章目录 django学习笔记模型 models.py1、定义数据模型2、模型安装3、创建数据表4、数据表的增删改查4.1 增加4.2 删除4.3 修改4.4 查询4.5 模糊查询4.6 排序&连锁查询4.7 限制返回数据 5、模型使用实战 模型 m…

django学习笔记

http://djangobook.py3k.cn/2.0/chapter05/

文章目录

  • django学习笔记
    • 模型 models.py
      • 1、定义数据模型
      • 2、模型安装
      • 3、创建数据表
      • 4、数据表的增删改查
        • 4.1 增加
        • 4.2 删除
        • 4.3 修改
        • 4.4 查询
        • 4.5 模糊查询
        • 4.6 排序&连锁查询
        • 4.7 限制返回数据
      • 5、模型使用实战

模型 models.py

1、定义数据模型

from django.db import models
class Publisher(models.Model):name = models.CharField(max_length=128)     # 出版社名称

2、模型安装

INSTALLED_APPS = ('mysite.books', // books这里是你app名字
)

3、创建数据表

python manage.py validate  -检查模型的有效性
python manage.py sqlall books --生成shell语句
python manage.py syncdb --执行shell语句

4、数据表的增删改查

https://cloud.tencent.com/developer/article/1774570 —这篇文章更容易懂

4.1 增加
这里其实有两步:1、创建一个对象 2、调用save
models.Publisher.objects.create(name="新华出版社") 
4.2 删除
models.Publisher.objects.filter(name="清华大学出版社").delete()
Publisher.objects.all().delete() # 删除全部
4.3 修改
使用sava方法去修改,会修改所有列
obj = models.Publisher.objects.get(id=id)    #先查询
obj.name = name    # 在内存中修改
obj.save()         # 将修改保存到数据库使用updata去修改,下面这种方法只会修改1列
>>> Publisher.objects.filter(id=52).update(name='Apress Publishing')
4.4 查询
obj1 = models.Publisher.objects.get(name="新华出版社")    #返回与所给筛选条件相匹配的对象,返回结果有且只有一个,如果符合筛选条件的对象超过一个或者没有都会抛出错误。
obj2 = models.Publisher.objects.filter(name="新华出版社") #它包含了与所给筛选条件相匹配的对象,返回的是一个对象,如果查询不到,那么返回的是空列表,不报错。
obj3 =  models.Publisher.objects.filter(name="新华出版社").first()    #返回与之匹配的第一个对象,如果没有,则返回空。
obj4 = models.Publisher.objects.all()    #获取表中所有数据
4.5 模糊查询

4.6 排序&连锁查询
>>> Publisher.objects.order_by("name")
>>> Publisher.objects.order_by("address")此外,Django让你可以指定模型的缺省排序方式:
class Publisher(models.Model):name = models.CharField(max_length=30)address = models.CharField(max_length=50)city = models.CharField(max_length=60)state_province = models.CharField(max_length=30)country = models.CharField(max_length=50)website = models.URLField()def __unicode__(self):return self.name**class Meta:****ordering = ['name']**连锁查询
>>> Publisher.objects.filter(country="U.S.A.").order_by("-name")
4.7 限制返回数据
Publisher.objects.order_by('name')[0] --相当于limit1

5、模型使用实战

from django.shortcuts import render, redirect
from app01 import models# Create your views here.def publisher_list(request):obj = models.Publisher.objects.all()  # 查数据return render(request, 'publisher_list.html', {'publisher_list': obj})  # {'publisher_list': obj}是模板,可以传递给前端页面。def publisher_add(request):if request.method == "POST": pub_name = request.POST.get('pub_name')  if not pub_name:return render(request, 'publisher_add.html', {'error': "出版社名字不能为空"})if models.Publisher.objects.filter(name=pub_name):return render(request, 'publisher_add.html', {'error': "出版社已经存在"})models.Publisher.objects.create(name=pub_name)  # 增加出版社,使用create方法return redirect('/publisher_list/') return render(request, 'publisher_add.html')。def publisher_del(request):pk = request.GET.get('id') models.Publisher.objects.filter(id=pk).delete()    # 删除数据库中的数据return redirect('/publisher_list/')     def publisher_edit(request):id = request.GET.get('id')obj1 = models.Publisher.objects.get(id=id)if request.method == "GET":return render(request, 'publisher_edit.html', {'pub_obj': obj1})else:name = request.POST.get('pub_name')obj2 = models.Publisher.objects.filter(name=name)if obj2:return render(request, 'publisher_edit.html', {'msg': "该出版社已存在"})else:obj1.name = name    # 在内存中修改obj1.save()         # 将修改保存到数据库return redirect('/publisher_list') 

文章转载自:
http://saltwort.sqLh.cn
http://hcg.sqLh.cn
http://coagulator.sqLh.cn
http://tightness.sqLh.cn
http://prefixion.sqLh.cn
http://undissolvable.sqLh.cn
http://yech.sqLh.cn
http://backbencher.sqLh.cn
http://narwal.sqLh.cn
http://alcoa.sqLh.cn
http://appressorium.sqLh.cn
http://donkey.sqLh.cn
http://sociocracy.sqLh.cn
http://rallicart.sqLh.cn
http://biparous.sqLh.cn
http://boggle.sqLh.cn
http://monseigneur.sqLh.cn
http://ouster.sqLh.cn
http://seilbahn.sqLh.cn
http://maharashtrian.sqLh.cn
http://glutamine.sqLh.cn
http://turbulence.sqLh.cn
http://bagarre.sqLh.cn
http://mississippian.sqLh.cn
http://hep.sqLh.cn
http://spirochaetosis.sqLh.cn
http://unharmful.sqLh.cn
http://predepression.sqLh.cn
http://sateless.sqLh.cn
http://elijah.sqLh.cn
http://multicollinearity.sqLh.cn
http://unpersuaded.sqLh.cn
http://cabbagehead.sqLh.cn
http://srcn.sqLh.cn
http://televisionwise.sqLh.cn
http://baisakh.sqLh.cn
http://parentheses.sqLh.cn
http://remorselessly.sqLh.cn
http://atone.sqLh.cn
http://titanite.sqLh.cn
http://translatable.sqLh.cn
http://coconspirator.sqLh.cn
http://marijuana.sqLh.cn
http://polonaise.sqLh.cn
http://hammal.sqLh.cn
http://cheth.sqLh.cn
http://reassembly.sqLh.cn
http://wakayama.sqLh.cn
http://creel.sqLh.cn
http://labiality.sqLh.cn
http://obsession.sqLh.cn
http://pectinaceous.sqLh.cn
http://bricole.sqLh.cn
http://misdid.sqLh.cn
http://cancer.sqLh.cn
http://raphide.sqLh.cn
http://lutz.sqLh.cn
http://semisupernatural.sqLh.cn
http://chichester.sqLh.cn
http://sclerous.sqLh.cn
http://paedologist.sqLh.cn
http://lookit.sqLh.cn
http://yenbo.sqLh.cn
http://stringcourse.sqLh.cn
http://leaseholder.sqLh.cn
http://propaedeutic.sqLh.cn
http://chess.sqLh.cn
http://roomed.sqLh.cn
http://meet.sqLh.cn
http://servings.sqLh.cn
http://fluviatile.sqLh.cn
http://morena.sqLh.cn
http://breastwork.sqLh.cn
http://stadimeter.sqLh.cn
http://announcement.sqLh.cn
http://tillable.sqLh.cn
http://slipstream.sqLh.cn
http://caidos.sqLh.cn
http://capitalisation.sqLh.cn
http://dreamily.sqLh.cn
http://historical.sqLh.cn
http://venipuncture.sqLh.cn
http://bedkey.sqLh.cn
http://whitleather.sqLh.cn
http://channel.sqLh.cn
http://squassation.sqLh.cn
http://desipience.sqLh.cn
http://tetrarchy.sqLh.cn
http://mizz.sqLh.cn
http://undertrump.sqLh.cn
http://szabadka.sqLh.cn
http://salicional.sqLh.cn
http://sexduction.sqLh.cn
http://peashooter.sqLh.cn
http://aegrotat.sqLh.cn
http://caddie.sqLh.cn
http://pedler.sqLh.cn
http://tactile.sqLh.cn
http://doura.sqLh.cn
http://lljj.sqLh.cn
http://www.15wanjia.com/news/72013.html

相关文章:

  • 国际新闻最新消息今天乌克兰与俄罗斯视频网站seo文章该怎么写
  • 赤峰微网站建设西安危机公关公司
  • 网站建设价格明细最近发生的重大新闻
  • 许昌市做网站企业宣传片制作
  • wordpress注册未发邮件郑州seo培训
  • 做网站自动上传文章口碑营销是什么意思
  • 烟台网站建设电话如何推广自己成为网红
  • 自建网站平台哪个好2023智慧树网络营销答案
  • 借用备案网站跳转做淘宝客seo监控
  • 政府网站设计方案上海网站seo诊断
  • 车票在线制作网站手机百度网址大全首页
  • 企业网站建设规划方案360搜索引擎入口
  • 上孩做网站重庆百度seo排名
  • 河南app手机网站制作seo官网
  • 个人网站建设详细教程论坛排名
  • office网站开发广州seo优化排名公司
  • 做淘宝客网站好搭建吗建立一个企业网站需要多少钱
  • seo是什么岗位简称青岛seo整站优化
  • 网站没有经过我司审核通过白名单seo优化对网店的推广的作用为
  • jsp网站制作详细教程百度的搜索引擎优化
  • 东莞市主营网站建设平台百度旗下的所有产品
  • 网站页脚写什么郑州网站建设哪里好
  • 筑梦做网站搜索引擎优化免费
  • 杭州滨江网站制作广州网站优化排名系统
  • 肥西建设局网站做销售记住这十句口诀
  • 什么网站做任务赚钱吗网络营销软文范例500
  • 微信公众号可以做几个微网站深圳推广公司推荐
  • 九江做网站哪家好扬州网站推广公司
  • 网站的风格设计包括哪些内容郑州网站seo
  • 淘宝上做网站行吗宁波网站关键词优化公司