首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

Django相关知识点笔记代码等

后端 51.21MB 14 需要积分: 1
立即下载

资源介绍:

Django相关知识点笔记代码等
import hashlib from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render from django.contrib.sessions.models import Session from django.conf import settings from .models import User # Create your views here. def reg_view(request): if request.method=='GET': return render(request,'user/register.html') elif request.method=='POST': username=request.POST['username'] password_1=request.POST['password_1'] password_2=request.POST['password_2'] if password_1!=password_2: return HttpResponse('两次密码输入不一致') m=hashlib.md5() m.update(password_1.encode()) password_m=m.hexdigest() old_users=User.objects.filter(username=username) print(old_users) if old_users: return HttpResponse('--用户名已注册--') try: user=User.objects.create(username=username,password=password_m) except Exception as e: print(f'----create user error {e}') return HttpResponse('用户名已注册') request.session['username']=username request.session['uid']=user.id return HttpResponseRedirect('/index') # Create your views here. def login_view(request): if request.method=='GET': if request.session.get('username') and request.session.get('uid'): return HttpResponseRedirect('/index') # return HttpResponse('session 已登录') session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME) print(f"request.COOKIES:{request.COOKIES}") try: session = Session.objects.get(session_key=session_key) if session: data = session.get_decoded() username = data.get('username') uid = data.get('uid') if username and uid: request.session['username'] = username request.session['uid'] = uid return HttpResponseRedirect('/index') # return HttpResponse('数据库 session 已登录') except Session.DoesNotExist: pass c_username=request.COOKIES.get('username') c_uid=request.COOKIES.get('uid') if c_username and c_uid: request.session['username']=c_username request.session['uid']=c_uid return HttpResponseRedirect('/index') # return HttpResponse('cookie 已登录') return render(request,'user/login.html') elif request.method=='POST': username=request.POST['username'] password=request.POST['password'] try: user=User.objects.get(username=username) except Exception as e: print(f'---login tests----{e}') return HttpResponse('----用户名或者密码错误------') m=hashlib.md5() m.update(password.encode()) if m.hexdigest()!=user.password: return HttpResponse('用户名或者密码错误') request.session['username']=username request.session['uid']=user.id resp=HttpResponseRedirect('/index') if 'remember' in request.POST: resp.set_cookie('username',username,3600*24*2) resp.set_cookie('uid',user.id,3600*24*2) return resp def logout_view(request): if 'username' in request.session: del request.session['username'] if 'uid' in request.session: del request.session['uid'] resp=HttpResponseRedirect('/index') if 'username' in request.COOKIES: resp.delete_cookie('username') if 'uid' in request.COOKIES: resp.delete_cookie('uid') return resp

资源文件列表:

python_Django.zip 大约有272个文件
  1. python_Django/
  2. python_Django/base1.assets/
  3. python_Django/base1.assets/1725465260974.png 160.92KB
  4. python_Django/base1.assets/1725548808581.png 292.7KB
  5. python_Django/base1.assets/1725548881340.png 363.08KB
  6. python_Django/base1.assets/1725549629044.png 223.9KB
  7. python_Django/base1.assets/1725550010194.png 294.12KB
  8. python_Django/base1.assets/1725761773299.png 380.78KB
  9. python_Django/base1.assets/1725761857314.png 388.11KB
  10. python_Django/base1.assets/1725761911371.png 481.94KB
  11. python_Django/base1.assets/1725762141863.png 442.44KB
  12. python_Django/base1.assets/1725762210005.png 215.19KB
  13. python_Django/base1.assets/1725762338510.png 357.69KB
  14. python_Django/base1.assets/1725762358463.png 184.73KB
  15. python_Django/base1.assets/1725763143634.png 291.7KB
  16. python_Django/base1.assets/1725763154608.png 320.67KB
  17. python_Django/base1.assets/1725763239723.png 332.06KB
  18. python_Django/base1.assets/1725783961734.png 126.12KB
  19. python_Django/base1.assets/1725785072768.png 183.02KB
  20. python_Django/base1.assets/1726239799714.png 332KB
  21. python_Django/base1.assets/1726451702408.png 460.61KB
  22. python_Django/base1.assets/1726451770792.png 437.46KB
  23. python_Django/base1.assets/1726451965918.png 498.45KB
  24. python_Django/base1.assets/1726452193379.png 573.23KB
  25. python_Django/base1.assets/1726453730797.png 356.82KB
  26. python_Django/base1.assets/1726453814936.png 477.27KB
  27. python_Django/base1.assets/1726469786586.png 8.99KB
  28. python_Django/base1.assets/1726469813477.png 178.04KB
  29. python_Django/base1.assets/1726469879894.png 286.32KB
  30. python_Django/base1.assets/1726469892820.png 226.83KB
  31. python_Django/base1.assets/1726469942465.png 202.63KB
  32. python_Django/base1.assets/1726469953572.png 219.43KB
  33. python_Django/base1.assets/1726470109386.png 281.81KB
  34. python_Django/base1.assets/1726470532728.png 316.34KB
  35. python_Django/base1.assets/1726470733375.png 146.31KB
  36. python_Django/base1.assets/1726470759252.png 381.93KB
  37. python_Django/base1.assets/1726470803695.png 434.73KB
  38. python_Django/base1.assets/1726470868749.png 338.42KB
  39. python_Django/base1.assets/1726470903881.png 228.01KB
  40. python_Django/base1.assets/1726471073098.png 459.78KB
  41. python_Django/base1.assets/1726471171828.png 160.13KB
  42. python_Django/base1.assets/1726471236641.png 285.78KB
  43. python_Django/base1.assets/1726471262526.png 199.58KB
  44. python_Django/base1.assets/1726471445970.png 381.44KB
  45. python_Django/base1.assets/1726471494404.png 369.99KB
  46. python_Django/base1.assets/1726471527056.png 324.41KB
  47. python_Django/base1.assets/1726471553731.png 316.39KB
  48. python_Django/base1.assets/1726471580379.png 212.28KB
  49. python_Django/base1.assets/1726471615866.png 312.57KB
  50. python_Django/base1.assets/1726471641802.png 271.05KB
  51. python_Django/base1.assets/1726471709256.png 393.82KB
  52. python_Django/base1.assets/1726471815717.png 362.16KB
  53. python_Django/base1.assets/1726471823458.png 208.14KB
  54. python_Django/base1.assets/1726478644721.png 366.87KB
  55. python_Django/base1.assets/1726478658421.png 374.98KB
  56. python_Django/base1.assets/1726478741240.png 167.27KB
  57. python_Django/base1.assets/1726478981897.png 322.37KB
  58. python_Django/base1.assets/1726479034621.png 562.4KB
  59. python_Django/base1.assets/1726479151558.png 168.98KB
  60. python_Django/base1.assets/1726479209718.png 278.05KB
  61. python_Django/base1.assets/1726479218312.png 219.26KB
  62. python_Django/base1.assets/1726479665348.png 198.93KB
  63. python_Django/base1.assets/1726479905092.png 688.88KB
  64. python_Django/base1.assets/1726480003248.png 425.34KB
  65. python_Django/base1.assets/1726480052025.png 469.49KB
  66. python_Django/base1.assets/1726480124718.png 362KB
  67. python_Django/base1.assets/1726480152890.png 281.15KB
  68. python_Django/base1.assets/1726480241078.png 156.91KB
  69. python_Django/base1.assets/1726480727883.png 323.78KB
  70. python_Django/base1.assets/1726481235314.png 35.1KB
  71. python_Django/base1.assets/1726481249517.png 336.19KB
  72. python_Django/base1.assets/1726481330685.png 423.14KB
  73. python_Django/base1.assets/1726481371565.png 132.25KB
  74. python_Django/base1.assets/1726481530928.png 238.56KB
  75. python_Django/base1.assets/1726544260880.png 367.6KB
  76. python_Django/base1.assets/1726544359274.png 352.6KB
  77. python_Django/base1.assets/1726544376742.png 320.88KB
  78. python_Django/base1.assets/1726544402657.png 420.09KB
  79. python_Django/base1.assets/1726544431619.png 185.66KB
  80. python_Django/base1.assets/1726544451139.png 255.29KB
  81. python_Django/base1.assets/1726561487847.png 426.18KB
  82. python_Django/base1.assets/1726562195369.png 266.1KB
  83. python_Django/base1.assets/1726562910770.png 37.3KB
  84. python_Django/base1.assets/1726562943877.png 39.54KB
  85. python_Django/base1.assets/1726564538745.png 29.33KB
  86. python_Django/base1.assets/1726564906320.png 254.66KB
  87. python_Django/base1.assets/1726564953102.png 295.68KB
  88. python_Django/base1.assets/1726564989979.png 215.12KB
  89. python_Django/base1.assets/1726565011676.png 336.55KB
  90. python_Django/base1.assets/1726565034569.png 203.4KB
  91. python_Django/base1.assets/1726565056983.png 269.57KB
  92. python_Django/base1.assets/1726565225270.png 325.07KB
  93. python_Django/base1.assets/1726565506895.png 38.97KB
  94. python_Django/base1.assets/1726565519470.png 396.48KB
  95. python_Django/base1.assets/1726565602924.png 339.41KB
  96. python_Django/base1.assets/1726565880095.png 88.42KB
  97. python_Django/base1.assets/1726566049108.png 426.21KB
  98. python_Django/base1.assets/1726566217246.png 364.31KB
  99. python_Django/base1.assets/1726566255274.png 238.71KB
  100. python_Django/base1.assets/1726566322623.png 226.41KB
  101. python_Django/base1.assets/1726566345120.png 325.36KB
  102. python_Django/base1.assets/1726566360179.png 264.76KB
  103. python_Django/base1.assets/1726566419127.png 203.51KB
  104. python_Django/base1.assets/1726566442765.png 315.71KB
  105. python_Django/base1.assets/1726587527934.png 694.61KB
  106. python_Django/base1.assets/1726587692763.png 68.17KB
  107. python_Django/base1.assets/1726587730957.png 269.03KB
  108. python_Django/base1.assets/1726587775072.png 338.2KB
  109. python_Django/base1.assets/1726587958675.png 516.8KB
  110. python_Django/base1.assets/1726587980556.png 263.32KB
  111. python_Django/base1.assets/1726588009333.png 444.91KB
  112. python_Django/base1.assets/1726588023996.png 280.91KB
  113. python_Django/base1.assets/1726588037693.png 359.9KB
  114. python_Django/base1.assets/1726588052694.png 266.44KB
  115. python_Django/base1.assets/1726588066891.png 395.76KB
  116. python_Django/base1.assets/1726588117320.png 446.61KB
  117. python_Django/base1.assets/1726588131539.png 110.93KB
  118. python_Django/base1.assets/1726671219019.png 369.75KB
  119. python_Django/base1.assets/1726671469720.png 226.59KB
  120. python_Django/base1.assets/1726671609750.png 322.51KB
  121. python_Django/base1.assets/1726672044911.png 116.41KB
  122. python_Django/base1.assets/1726672083154.png 199.78KB
  123. python_Django/base1.assets/1726672147280.png 146.88KB
  124. python_Django/base1.assets/1726672167104.png 184.1KB
  125. python_Django/base1.assets/1726672196227.png 404.06KB
  126. python_Django/base1.assets/1726969382215.png 390.09KB
  127. python_Django/base1.assets/1726969560997.png 333.58KB
  128. python_Django/base1.assets/1726969596002.png 347.02KB
  129. python_Django/base1.assets/1726969677296.png 357.54KB
  130. python_Django/base1.assets/1726969738166.png 355.58KB
  131. python_Django/base1.assets/1726969760783.png 165.1KB
  132. python_Django/base1.assets/1726969799566.png 265.17KB
  133. python_Django/base1.assets/1726969888244.png 378KB
  134. python_Django/base1.assets/1726969981214.png 278.39KB
  135. python_Django/base1.assets/1726970012298.png 364.21KB
  136. python_Django/base1.assets/1726970189300.png 341.08KB
  137. python_Django/base1.assets/1726970507861.png 291.81KB
  138. python_Django/base1.assets/1726970575539.png 291.24KB
  139. python_Django/base1.assets/1726970668167.png 484.92KB
  140. python_Django/base1.assets/1726970723958.png 568.67KB
  141. python_Django/base1.assets/1726970871041.png 262.42KB
  142. python_Django/base1.assets/1726970917009.png 244.12KB
  143. python_Django/base1.assets/1726970979826.png 245.3KB
  144. python_Django/base1.assets/1726971029430.png 504.32KB
  145. python_Django/base1.assets/1726971208949.png 375.62KB
  146. python_Django/base1.assets/1726985248388.png 216.95KB
  147. python_Django/base1.assets/1726985557008.png 300.17KB
  148. python_Django/base1.assets/1726985896122.png 396.93KB
  149. python_Django/base1.assets/1726986020205.png 287.21KB
  150. python_Django/base1.assets/1726986917677.png 57.53KB
  151. python_Django/base1.assets/1726986927597.png 37.44KB
  152. python_Django/base1.assets/1726987048008.png 56.11KB
  153. python_Django/base1.assets/1726987120237.png 413.15KB
  154. python_Django/base1.assets/1726987128352.png 311.87KB
  155. python_Django/base1.assets/1726987666126.png 361.29KB
  156. python_Django/base1.assets/1726988546155.png 350.11KB
  157. python_Django/base1.assets/1726990873285.png 331.44KB
  158. python_Django/base1.assets/1726991166645.png 336.39KB
  159. python_Django/base1.assets/1726991238290.png 300.84KB
  160. python_Django/base1.assets/1726991334595.png 407.95KB
  161. python_Django/base1.assets/1726991378420.png 196.7KB
  162. python_Django/base1.assets/1726991800776.png 487.17KB
  163. python_Django/base1.assets/1726991900132.png 47.48KB
  164. python_Django/base1.assets/1726991979964.png 265.2KB
  165. python_Django/base1.assets/1726992050474.png 167.28KB
  166. python_Django/base1.assets/1726992190142.png 403.35KB
  167. python_Django/base1.assets/1726992506009.png 232.48KB
  168. python_Django/base1.assets/1727004949915.png 412.2KB
  169. python_Django/base1.assets/1727007431299.png 409.28KB
  170. python_Django/base1.assets/1727007537165.png 107.56KB
  171. python_Django/base1.assets/1727010981790.png 50.27KB
  172. python_Django/base1.assets/1727016442526.png 229.81KB
  173. python_Django/base1.assets/1727019994593.png 362.34KB
  174. python_Django/base1.assets/1727101335723.png 345.81KB
  175. python_Django/base1.assets/1727102483412.png 244.94KB
  176. python_Django/base1.assets/1727102490410.png 234.73KB
  177. python_Django/base1.assets/1727102758141.png 350.17KB
  178. python_Django/base1.assets/1727103845485.png 308.35KB
  179. python_Django/base1.assets/1727104097580.png 317.36KB
  180. python_Django/base1.assets/1727104110112.png 389.41KB
  181. python_Django/base1.assets/1727104140203.png 400.84KB
  182. python_Django/base1.assets/1727104317133.png 281.9KB
  183. python_Django/base1.assets/1727104414872.png 344.48KB
  184. python_Django/base1.assets/1727104741939.png 191.77KB
  185. python_Django/base1.assets/1727104749582.png 222.45KB
  186. python_Django/base1.assets/1727104752094.png 222.45KB
  187. python_Django/base1.assets/1727104818205.png 388.65KB
  188. python_Django/base1.md 11.81KB
  189. python_Django/tedu_note/
  190. python_Django/tedu_note/.idea/
  191. python_Django/tedu_note/.idea/inspectionProfiles/
  192. python_Django/tedu_note/.idea/inspectionProfiles/profiles_settings.xml 174B
  193. python_Django/tedu_note/.idea/inspectionProfiles/Project_Default.xml 9.73KB
  194. python_Django/tedu_note/.idea/misc.xml 305B
  195. python_Django/tedu_note/.idea/modules.xml 277B
  196. python_Django/tedu_note/.idea/tedu_note.iml 452B
  197. python_Django/tedu_note/.idea/vcs.xml 188B
  198. python_Django/tedu_note/.idea/workspace.xml 2.55KB
  199. python_Django/tedu_note/index/
  200. python_Django/tedu_note/index/admin.py 63B
  201. python_Django/tedu_note/index/apps.py 142B
  202. python_Django/tedu_note/index/migrations/
  203. python_Django/tedu_note/index/migrations/__init__.py
  204. python_Django/tedu_note/index/migrations/__pycache__/
  205. python_Django/tedu_note/index/migrations/__pycache__/__init__.cpython-37.pyc 133B
  206. python_Django/tedu_note/index/models.py 57B
  207. python_Django/tedu_note/index/templates/
  208. python_Django/tedu_note/index/templates/index/
  209. python_Django/tedu_note/index/templates/index/index.html 887B
  210. python_Django/tedu_note/index/templates/__init__.py
  211. python_Django/tedu_note/index/tests.py 60B
  212. python_Django/tedu_note/index/urls.py
  213. python_Django/tedu_note/index/views.py 133B
  214. python_Django/tedu_note/index/__init__.py
  215. python_Django/tedu_note/index/__pycache__/
  216. python_Django/tedu_note/index/__pycache__/admin.cpython-37.pyc 163B
  217. python_Django/tedu_note/index/__pycache__/apps.cpython-37.pyc 393B
  218. python_Django/tedu_note/index/__pycache__/models.cpython-37.pyc 160B
  219. python_Django/tedu_note/index/__pycache__/views.cpython-37.pyc 299B
  220. python_Django/tedu_note/index/__pycache__/__init__.cpython-37.pyc 122B
  221. python_Django/tedu_note/manage.py 665B
  222. python_Django/tedu_note/note/
  223. python_Django/tedu_note/note/admin.py 63B
  224. python_Django/tedu_note/note/apps.py 140B
  225. python_Django/tedu_note/note/migrations/
  226. python_Django/tedu_note/note/migrations/__init__.py
  227. python_Django/tedu_note/note/models.py 401B
  228. python_Django/tedu_note/note/templates/
  229. python_Django/tedu_note/note/templates/note/
  230. python_Django/tedu_note/note/templates/note/add_note.html 381B
  231. python_Django/tedu_note/note/templates/note/list_note.html 132B
  232. python_Django/tedu_note/note/templates/note/__init__.py
  233. python_Django/tedu_note/note/templates/__init__.py
  234. python_Django/tedu_note/note/tests.py 60B
  235. python_Django/tedu_note/note/urls.py 102B
  236. python_Django/tedu_note/note/views.py 1.03KB
  237. python_Django/tedu_note/note/__init__.py
  238. python_Django/tedu_note/tedu_note/
  239. python_Django/tedu_note/tedu_note/asgi.py 395B
  240. python_Django/tedu_note/tedu_note/settings.py 3.29KB
  241. python_Django/tedu_note/tedu_note/urls.py 904B
  242. python_Django/tedu_note/tedu_note/wsgi.py 395B
  243. python_Django/tedu_note/tedu_note/__init__.py
  244. python_Django/tedu_note/tedu_note/__pycache__/
  245. python_Django/tedu_note/tedu_note/__pycache__/settings.cpython-37.pyc 2.29KB
  246. python_Django/tedu_note/tedu_note/__pycache__/urls.cpython-37.pyc 1021B
  247. python_Django/tedu_note/tedu_note/__pycache__/wsgi.cpython-37.pyc 533B
  248. python_Django/tedu_note/tedu_note/__pycache__/__init__.cpython-37.pyc 126B
  249. python_Django/tedu_note/user/
  250. python_Django/tedu_note/user/admin.py 63B
  251. python_Django/tedu_note/user/apps.py 140B
  252. python_Django/tedu_note/user/migrations/
  253. python_Django/tedu_note/user/migrations/__init__.py
  254. python_Django/tedu_note/user/migrations/__pycache__/
  255. python_Django/tedu_note/user/migrations/__pycache__/__init__.cpython-37.pyc 132B
  256. python_Django/tedu_note/user/models.py 393B
  257. python_Django/tedu_note/user/templates/
  258. python_Django/tedu_note/user/templates/user/
  259. python_Django/tedu_note/user/templates/user/login.html 467B
  260. python_Django/tedu_note/user/templates/user/register.html 484B
  261. python_Django/tedu_note/user/templates/__init__.py
  262. python_Django/tedu_note/user/tests.py 60B
  263. python_Django/tedu_note/user/urls.py 181B
  264. python_Django/tedu_note/user/views.py 3.63KB
  265. python_Django/tedu_note/user/__init__.py
  266. python_Django/tedu_note/user/__pycache__/
  267. python_Django/tedu_note/user/__pycache__/admin.cpython-37.pyc 162B
  268. python_Django/tedu_note/user/__pycache__/apps.cpython-37.pyc 390B
  269. python_Django/tedu_note/user/__pycache__/models.cpython-37.pyc 713B
  270. python_Django/tedu_note/user/__pycache__/urls.cpython-37.pyc 267B
  271. python_Django/tedu_note/user/__pycache__/views.cpython-37.pyc 2.23KB
  272. python_Django/tedu_note/user/__pycache__/__init__.cpython-37.pyc 121B
0评论
提交 加载更多评论
其他资源 23级虚拟现实技术一班 2024-2025学年贫困认定.zip
23级虚拟现实技术一班 2024-2025学年贫困认定.zip
23级虚拟现实技术一班   2024-2025学年贫困认定.zip
基于CH32的全屋灯光智能控制系统源代码(项目分享-小白练手项目)
基于CH32的全屋灯光智能控制系统源代码(项目分享-小白练手项目)
Bios Acer 掠夺者2023款
Bios Acer 掠夺者2023款
ffmpeg7.0 Android库
ffmpeg7.0 Android 库
超星学习通学习专用浏览器
超星学习通学习专用浏览器
超星学习通学习专用浏览器
用python+kivy实现简易的电子白板功能
用python+kivy实现简易的白板功能:具有以下功能: 1.显示画笔轨迹 2.设置画笔的颜色,可选择10种颜色,可修改代码添加 3.设置线条的粗细,也叫线宽(提供三个选择:细、正常、粗) 4.清屏
stm32f4+ads1278.zip
stm32f4+ads1278采集8个通道
基于springcloud的脚手架(smart-cloud)示例.zip
基于springcloud的脚手架(smart-cloud)示例,支持服务合并部署与拆分部署、接口加解密签名、日志数据脱敏、接口数