{"id":5689,"date":"2022-04-03T07:08:15","date_gmt":"2022-04-02T23:08:15","guid":{"rendered":"https:\/\/egonlin.com\/?p=5689"},"modified":"2022-04-26T14:32:25","modified_gmt":"2022-04-26T06:32:25","slug":"%e6%89%b9%e9%87%8f%e6%8f%92%e5%85%a5%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=5689","title":{"rendered":"\u6279\u91cf\u63d2\u5165\u6570\u636e"},"content":{"rendered":"<h1>\u6279\u91cf\u63d2\u5165\u6570\u636e<\/h1>\n<p>\u9879\u76ee\u9700\u6c42:\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95eedjango\u540e\u7aef\u67d0\u4e00\u6761url(\u5982:127.0.0.1:8080\/index\/)\uff0c\u5b9e\u65f6\u671d\u6570\u636e\u5e93\u4e2d\u751f\u6210\u4e00\u5343\u6761\u6570\u636e\u5e76\u5c06\u751f\u6210\u7684\u6570\u636e\u67e5\u8be2\u51fa\u6765\uff0c\u5e76\u5c55\u793a\u5230\u524d\u7aef\u9875\u9762<\/p>\n<h4>urls.py<\/h4>\n<pre><code class=\"language-python\">from django.conf.urls import url\nfrom app01 import views\n\nurlpatterns = [\n  url(r&#039;^get_book\/&#039;,views.get_book)\n]<\/code><\/pre>\n<h4>models.py<\/h4>\n<pre><code class=\"language-python\">from django.db import models\n\nclass Book(models.Model):\n  title = models.CharField(max_length=64)<\/code><\/pre>\n<h4>views.py<\/h4>\n<pre><code class=\"language-python\">from django.shortcuts import render, HttpResponse, redirect\nfrom app01 import models\n\ndef get_book(request):\n  # for\u5faa\u73af\u63d2\u51651000\u6761\u6570\u636e\n  for i in range(1000):\n    models.Book.objects.create(name=&#039;\u7b2c%s\u672c\u4e66&#039;%i)\n  # \u5c06\u63d2\u5165\u7684\u6570\u636e\u518d\u67e5\u8be2\u51fa\u6765\n  book_queryset = models.Book.objcets.all()\n  return render(request,&#039;get_book.html&#039;,locals())  # \u5c06\u67e5\u8be2\u51fa\u6765\u7684\u6570\u636e\u4f20\u9012\u7ed9html\u9875\u9762<\/code><\/pre>\n<h4>template\/get_book.html<\/h4>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;title&gt;Title&lt;\/title&gt;\n    &lt;script src=&quot;https:\/\/cdn.bootcss.com\/jquery\/3.4.1\/jquery.min.js&quot;&gt;&lt;\/script&gt;\n    {% load static %}\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;{% static &#039;bootstrap-3.3.7-dist\/css\/bootstrap.min.css&#039; %}&quot;&gt;\n    &lt;link rel=&quot;stylesheet&quot; href=&quot;{% static &#039;dist\/sweetalert.css&#039; %}&quot;&gt;\n    &lt;script src=&quot;{% static &#039;bootstrap-3.3.7-dist\/js\/bootstrap.min.js&#039; %}&quot;&gt;&lt;\/script&gt;\n    &lt;script src=&quot;{% static &#039;dist\/sweetalert.min.js&#039; %}&quot;&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div class=&quot;container&quot;&gt;\n    &lt;div class=&quot;row&quot;&gt;\n        &lt;div class=&quot;col-md-8 col-md-offset-2&quot;&gt;\n            {% for book in book_queryset %}\n            &lt;p&gt;{{ book.title }}&lt;\/p&gt;\n            {% endfor %}\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e66\u5199\u5b8c\u6bd5\u540e\u542f\u52a8django\u540e\u7aef\uff0c\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u4f1a\u53d1\u73b0\u6d4f\u89c8\u5668\u4f1a\u6709\u4e00\u4e2a\u660e\u663e\u7684\u5361\u987f\u7b49\u5f85\u65f6\u95f4\uff0c\u8fd9\u4e0d\u662f\u4f60\u7684\u6d4f\u89c8\u5668\u6709\u95ee\u9898\u4e5f\u4e0d\u662f\u7f51\u901f\u6709\u95ee\u9898\uff0c\u800c\u662f\u540e\u7aef\u518d\u4e0d\u505c\u7684\u64cd\u4f5c\u6570\u636e\u5e93\uff0c\u8017\u65f6\u8f83\u957f\uff0c\u5927\u6982\u9700\u8981\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\u624d\u80fd\u6b63\u5e38\u770b\u5230\u521a\u521a\u63d2\u5165\u76841000\u6761\u6570\u636e\uff0c\u5f88\u660e\u663e\u8fd9\u6837\u64cd\u4f5c\u6570\u636e\u5e93\u7684\u6548\u7387\u592a\u4f4e\uff0c\u90a3\u6709\u6ca1\u6709\u4e00\u79cd\u65b9\u5f0f\u662f\u4e13\u95e8\u7528\u6765\u6279\u91cf\u64cd\u4f5c\u6570\u636e\u5e93\u7684\u5462\uff1f\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff01<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u6279\u91cf\u63d2\u5165\u6570\u636e-1.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u6279\u91cf\u63d2\u5165\u6570\u636e-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>bulk_create\u65b9\u6cd5<\/h2>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"5689\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"5689\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"cb659705e6\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"62dfcfae4b\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>\u6279\u91cf\u63d2\u5165\u6570\u636e \u9879\u76ee\u9700\u6c42:\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95eedjango\u540e\u7aef\u67d0\u4e00\u6761url(\u5982:127.0.0.1:8080\/index [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[385,386],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5689"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5689"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5689\/revisions"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}