当前位置:网站首页>djanjo fourth training
djanjo fourth training
2022-08-08 07:34:00 【[email protected]】
1.Django project file

- settings.py is the overall configuration of the project
- urls.py project URL configuration file
- wsgi.py Project WSGI Compatible Web Server Portal
- manage.py Project management file, mainly used for command line
Add setting.py after 2.app is created

3.pycharm link database

4. Front-end and back-end interactions
4.1 Front-end implementation
Install node.js
Install qs.stringify
npm install qs and npm install querystring4.2 Configuration of Config.json
Modify the following part of the code:
1."deviceConfig": {"default": {"process": "com.huawei.hiworld.example","supportBackup": false,"network": {"cleartextTraffic": true}2."reqPermissions": [{"name": "ohos.permission.GET_NETWORK_INFO"},{"name": "ohos.permission.SET_NETWORK_INFO"},{"name": "ohos.permission.INTERNET"}],4.3 Front-end js code
import router from '@system.router';import fetch from '@system.fetch';import qs from 'querystring';export default {data:{winfo:""},onClick(){fetch.fetch({url:'', //Enter the backend pathdata: qs.stringify({'id':'1'}),//VerifyresponseType:"json",//The parameter type of the requestmethod:"POST",success:(resp)=>{this.winfo = resp.data;//Assign the acquired backend data to winfoconsole.log("Returned data: "+this.winfo);//Print out the data},fail:(resp)=>{this.winfo = resp.data;console.log("Failed to get data: "+this.winfo)}});}}4.4 Backend Django code
from django.shortcuts import renderfrom django.http import HttpResponsefrom django.shortcuts import renderfrom student import modelsfrom rest_framework.views import APIViewclass AppReq1(APIView):def post(self, request):re = models.Students.objects.filter(Age=20)arr = []for i in re:content = {'Name': i.Name, 'Email': i.Email, 'Age': i.Age}arr.append(content)print(arr)print(type(arr))ID = request.data.get('id')# username = request.data.get('username')# password = request.data.get('password')print(ID)# print(username)# print(password)return HttpResponse(arr)4.5 Effect Display


原网站
版权声明
本文为[[email protected]~@]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/220/202208080704477585.html
边栏推荐
猜你喜欢
随机推荐
小程序云开发服务端(云函数-函数式编程)数据库取出数据突破限制
剪切字符串函数
C语言内存分配相关知识
如何解决大团队需求交付周期长的问题?
C# FileSystemWatcher 实时监控文件的增加、修改、重命名和删除实例
论文解读:多层肽 - 蛋白质相互作用预测的深度学习框架
【枚举】连续因子
物联网安全-单向散列算法
Monorepo[单一代码库] 与MicroService[微服务] 架构
蓝牙5.2新特性 - Enhance ATT
进程间的五种通信方法
每日一题47-48
论文解读:《多层肽 - 蛋白质相互作用预测的深度学习框架》
Gstreamer调试方式
步进电机工作原理
物联网安全-消息认证码
信息学奥赛一本通 1923:【03NOIP普及组】数字游戏 | 洛谷 P1043 [NOIP2003 普及组] 数字游戏
Integer缓存池
Properties文件的读取与保存
一篇文章带你解读蓝牙配对绑定









