{"title":"Menulis tampilan","version":"3.0","locale":"id","docname":"topics/http/views","url":"/id/3.0/topics/http/views/","canonical":"https://djangodocs.dev/id/3.0/topics/http/views/","summary":"A view function, or view for short, is a Python function that takes a Web request and returns a Web response.","html":"<h1>Menulis tampilan<a class=\"heading-anchor\" href=\"#writing-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>A view function, or <em>view</em> for short, is a Python function that takes a\nWeb request and returns a Web response. This response can be the HTML contents\nof a Web page, or a redirect, or a 404 error, or an XML document, or an image .\n. . or anything, really. The view itself contains whatever arbitrary logic is\nnecessary to return that response. This code can live anywhere you want, as long\nas it's on your Python path. There's no other requirement--no &quot;magic,&quot; so to\nspeak. For the sake of putting the code <em>somewhere</em>, the convention is to\nput views in a file called <code class=\"docutils literal notranslate\">views.py</code>, placed in your project or\napplication directory.</p>\n<section id=\"a-simple-view\">\n<h2>Tampilan sederhana<a class=\"heading-anchor\" href=\"#a-simple-view\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Disini adalah tampilan yang mengembalikan data dan waktu saat ini, sebagai sebuah dokumen HTML:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.http</span> <span class=\"kn\">import</span> HttpResponse\n<span class=\"kn\">import</span> <span class=\"nn\">datetime</span>\n\n<span class=\"k\">def</span> <span class=\"nf\">current_datetime</span><span class=\"p\">(</span>request<span class=\"p\">):</span>\n    now <span class=\"o\">=</span> datetime<span class=\"o\">.</span>datetime<span class=\"o\">.</span>now<span class=\"p\">()</span>\n    html <span class=\"o\">=</span> <span class=\"s2\">&quot;&lt;html&gt;&lt;body&gt;It is now </span><span class=\"si\">%s</span><span class=\"s2\">.&lt;/body&gt;&lt;/html&gt;&quot;</span> <span class=\"o\">%</span> now\n    <span class=\"k\">return</span> HttpResponse<span class=\"p\">(</span>html<span class=\"p\">)</span>\n</code></pre></div>\n<p>Mari kita melangkah melalui kode ini satu baris pada saat bersamaan:</p>\n<ul>\n<li><p>Pertama, kami impor kelas <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> dari modul <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#module-django.http\" title=\"django.http: Classes dealing with HTTP requests and responses.\"><code class=\"xref py py-mod docutils literal notranslate\">django.http</code></a>, bersama dengan pustaka <code class=\"docutils literal notranslate\">datetime</code> Python.</p></li>\n<li><p>Next, we define a function called <code class=\"docutils literal notranslate\">current_datetime</code>. This is the view\nfunction. Each view function takes an <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpRequest\" title=\"django.http.HttpRequest\"><code class=\"xref py py-class docutils literal notranslate\">HttpRequest</code></a>\nobject as its first parameter, which is typically named <code class=\"docutils literal notranslate\">request</code>.</p>\n<p>Note that the name of the view function doesn't matter; it doesn't have to\nbe named in a certain way in order for Django to recognize it. We're\ncalling it <code class=\"docutils literal notranslate\">current_datetime</code> here, because that name clearly indicates\nwhat it does.</p>\n</li>\n<li><p>Tampilan mengembalikan sebuah obyek <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> yang mengandung tanggapan dibangkitkan. Setiap fungsi tampilan bertanggungjawab untuk mengembalikan sebuah obyek <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a>. (ada pengecualian, tetapi kita akan kesana nanti.)</p></li>\n</ul>\n<aside class=\"admonition-django-s-time-zone admonition\" role=\"note\">\n<p class=\"admonition-title\">Zona Waktu Django</p>\n<p>Django menyertakan sebuah pengaturan <a class=\"reference internal\" href=\"/id/3.0/ref/settings/#std-setting-TIME_ZONE\"><code class=\"xref std std-setting docutils literal notranslate\">TIME_ZONE</code></a> yang awalan pada <code class=\"docutils literal notranslate\">America/Chicago</code>. Ini mungkin bukan dimana anda tinggal, jadi anda mungkin ingin merubah itu dalam berkas pengaturan anda.</p>\n</aside>\n</section>\n<section id=\"mapping-urls-to-views\">\n<h2>Memetakan URL ke tampilan<a class=\"heading-anchor\" href=\"#mapping-urls-to-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Jadi, untuk mengikhtisarkan, fungsi tampilan ini mengembalikan sebuah halaman HTML yang menyertakan tanggal dan waktu saat ini. Untuk menampilkan tampilan ini pada URL tertentu, anda akan butuh membuat sebuah <em>URLconf</em>; lihat <a class=\"reference internal\" href=\"/id/3.0/topics/http/urls/\"><span class=\"doc\">Pengirim URL</span></a> untuk petunjuk.</p>\n</section>\n<section id=\"returning-errors\">\n<h2>Mengembalikan kesalahan<a class=\"heading-anchor\" href=\"#returning-errors\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django provides help for returning HTTP error codes. There are subclasses of\n<a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> for a number of common HTTP status codes\nother than 200 (which means <em>&quot;OK&quot;</em>). You can find the full list of available\nsubclasses in the <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#ref-httpresponse-subclasses\"><span class=\"std std-ref\">request/response</span></a>\ndocumentation. Return an instance of one of those subclasses instead of a\nnormal <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> in order to signify an error. For\nexample:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.http</span> <span class=\"kn\">import</span> HttpResponse<span class=\"p\">,</span> HttpResponseNotFound\n\n<span class=\"k\">def</span> <span class=\"nf\">my_view</span><span class=\"p\">(</span>request<span class=\"p\">):</span>\n    <span class=\"c1\"># ...</span>\n    <span class=\"k\">if</span> foo<span class=\"p\">:</span>\n        <span class=\"k\">return</span> HttpResponseNotFound<span class=\"p\">(</span><span class=\"s1\">&#39;&lt;h1&gt;Page not found&lt;/h1&gt;&#39;</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"k\">return</span> HttpResponse<span class=\"p\">(</span><span class=\"s1\">&#39;&lt;h1&gt;Page was found&lt;/h1&gt;&#39;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Tidak ada subkelas khusus untuk setiap kemungkinan kode tanggapan HTTP, sejak banyak dari mereka tidak akan menjadi yang umum. Bagaimanapun, seperti didokumentasikan dalam dokumentasi <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a>, anda dapat juga melewatkan kode keadaan HTTP kedalam pembangun untuk <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> untuk membuat kelas kembalian untuk kode keadaan apapun anda sukai. Sebagai contoh:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.http</span> <span class=\"kn\">import</span> HttpResponse\n\n<span class=\"k\">def</span> <span class=\"nf\">my_view</span><span class=\"p\">(</span>request<span class=\"p\">):</span>\n    <span class=\"c1\"># ...</span>\n\n    <span class=\"c1\"># Return a &quot;created&quot; (201) response code.</span>\n    <span class=\"k\">return</span> HttpResponse<span class=\"p\">(</span>status<span class=\"o\">=</span><span class=\"mi\">201</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Karena kesalahan 404 sejauh ini paling umum kesalahan HTTP, ada sebuah cara paling mudah untuk menangani kesalahan-kesalahan tersebut.</p>\n<section id=\"the-http404-exception\">\n<h3>Pengecualian <code class=\"docutils literal notranslate\">Http404</code><a class=\"heading-anchor\" href=\"#the-http404-exception\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.http.Http404\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-prename descclassname\">django.http.</span><span class=\"sig-name descname\">Http404</span><a class=\"heading-anchor\" href=\"#django.http.Http404\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Ketika anda mengembalikan sebuah kesalahan seperti <a class=\"reference internal\" href=\"/id/3.0/ref/request-response/#django.http.HttpResponseNotFound\" title=\"django.http.HttpResponseNotFound\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponseNotFound</code></a>, anda bertanggung jawab untuk menentukan HTML dari menghasilkan halaman kesalahan:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">return</span> HttpResponseNotFound<span class=\"p\">(</span><span class=\"s1\">&#39;&lt;h1&gt;Page not found&lt;/h1&gt;&#39;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Untuk kenyamanan, dan karena itu adalah ide bagus untuk memiliki halaman kesalahan 404 tetap terhadap situs anda, Django menyediakan sebuah pengecualian <code class=\"docutils literal notranslate\">Http404</code> pada titik apapun dalam fungsi tampilan, Django akan menangkap itu dan mengembalikan halaman kesalahan standar untuk aplikasi anda, bersama dengan sebuah kode kesalahan HTTP 404.</p>\n<p>Contoh penggunaan:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.http</span> <span class=\"kn\">import</span> Http404\n<span class=\"kn\">from</span> <span class=\"nn\">django.shortcuts</span> <span class=\"kn\">import</span> render\n<span class=\"kn\">from</span> <span class=\"nn\">polls.models</span> <span class=\"kn\">import</span> Poll\n\n<span class=\"k\">def</span> <span class=\"nf\">detail</span><span class=\"p\">(</span>request<span class=\"p\">,</span> poll_id<span class=\"p\">):</span>\n    <span class=\"k\">try</span><span class=\"p\">:</span>\n        p <span class=\"o\">=</span> Poll<span class=\"o\">.</span>objects<span class=\"o\">.</span>get<span class=\"p\">(</span>pk<span class=\"o\">=</span>poll_id<span class=\"p\">)</span>\n    <span class=\"k\">except</span> Poll<span class=\"o\">.</span>DoesNotExist<span class=\"p\">:</span>\n        <span class=\"k\">raise</span> Http404<span class=\"p\">(</span><span class=\"s2\">&quot;Poll does not exist&quot;</span><span class=\"p\">)</span>\n    <span class=\"k\">return</span> render<span class=\"p\">(</span>request<span class=\"p\">,</span> <span class=\"s1\">&#39;polls/detail.html&#39;</span><span class=\"p\">,</span> <span class=\"p\">{</span><span class=\"s1\">&#39;poll&#39;</span><span class=\"p\">:</span> p<span class=\"p\">})</span>\n</code></pre></div>\n<p>Untuk menampilkan HTML disesuaikan ketika Django mengembalikan sebuah 404, anda dapat membuat sebuah cetakan HTML bernama <code class=\"docutils literal notranslate\">404.html</code> dan menempatkan itu dalam tingkat atas dari pohon cetakan anda. Cetakan anda kemudian akan dilayani ketika <a class=\"reference internal\" href=\"/id/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> disetel menjadi <code class=\"docutils literal notranslate\">False</code>.</p>\n<p>Ketika <a class=\"reference internal\" href=\"/id/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> adalah <code class=\"docutils literal notranslate\">True</code>, anda dapat menyediakan sebuah pesan pada <code class=\"docutils literal notranslate\">Http404</code> dan itu akan muncul dalam cetakan mencari kesalahan 404 standar. Gunakan pesan-pesan ini untuk tujuan mencari kesalahan; mereka umumnya tidak cocok untuk digunakan dalam produksi cetakan 404.</p>\n</section>\n</section>\n<section id=\"customizing-error-views\">\n<span id=\"id1\"></span><h2>Menyesuaikan tampilan kesalahan<a class=\"heading-anchor\" href=\"#customizing-error-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The default error views in Django should suffice for most Web applications,\nbut can easily be overridden if you need any custom behavior. Specify the\nhandlers as seen below in your URLconf (setting them anywhere else will have no\neffect).</p>\n<p>Tampilan <a class=\"reference internal\" href=\"/id/3.0/ref/views/#django.views.defaults.page_not_found\" title=\"django.views.defaults.page_not_found\"><code class=\"xref py py-func docutils literal notranslate\">page_not_found()</code></a> ditimpa oleh <a class=\"reference internal\" href=\"/id/3.0/ref/urls/#django.conf.urls.handler404\" title=\"django.conf.urls.handler404\"><code class=\"xref py py-data docutils literal notranslate\">handler404</code></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>handler404 <span class=\"o\">=</span> <span class=\"s1\">&#39;mysite.views.my_custom_page_not_found_view&#39;</span>\n</code></pre></div>\n<p>Tampilan <a class=\"reference internal\" href=\"/id/3.0/ref/views/#django.views.defaults.server_error\" title=\"django.views.defaults.server_error\"><code class=\"xref py py-func docutils literal notranslate\">server_error()</code></a> ditimpa oleh <a class=\"reference internal\" href=\"/id/3.0/ref/urls/#django.conf.urls.handler500\" title=\"django.conf.urls.handler500\"><code class=\"xref py py-data docutils literal notranslate\">handler500</code></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>handler500 <span class=\"o\">=</span> <span class=\"s1\">&#39;mysite.views.my_custom_error_view&#39;</span>\n</code></pre></div>\n<p>Tampilan <a class=\"reference internal\" href=\"/id/3.0/ref/views/#django.views.defaults.permission_denied\" title=\"django.views.defaults.permission_denied\"><code class=\"xref py py-func docutils literal notranslate\">permission_denied()</code></a> ditimpa oleh <a class=\"reference internal\" href=\"/id/3.0/ref/urls/#django.conf.urls.handler403\" title=\"django.conf.urls.handler403\"><code class=\"xref py py-data docutils literal notranslate\">handler403</code></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>handler403 <span class=\"o\">=</span> <span class=\"s1\">&#39;mysite.views.my_custom_permission_denied_view&#39;</span>\n</code></pre></div>\n<p>Tampilan <a class=\"reference internal\" href=\"/id/3.0/ref/views/#django.views.defaults.bad_request\" title=\"django.views.defaults.bad_request\"><code class=\"xref py py-func docutils literal notranslate\">bad_request()</code></a> ditimpa oleh <a class=\"reference internal\" href=\"/id/3.0/ref/urls/#django.conf.urls.handler400\" title=\"django.conf.urls.handler400\"><code class=\"xref py py-data docutils literal notranslate\">handler400</code></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>handler400 <span class=\"o\">=</span> <span class=\"s1\">&#39;mysite.views.my_custom_bad_request_view&#39;</span>\n</code></pre></div>\n<aside class=\"admonition admonition-seealso\" role=\"note\">\n<p class=\"admonition-title\">Lihat juga</p>\n<p>Gunakan pengaturan <a class=\"reference internal\" href=\"/id/3.0/ref/settings/#std-setting-CSRF_FAILURE_VIEW\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_FAILURE_VIEW</code></a> untuk menimpa tampilan kesalahan CSRF.</p>\n</aside>\n<section id=\"testing-custom-error-views\">\n<h3>Testing custom error views<a class=\"heading-anchor\" href=\"#testing-custom-error-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>To test the response of a custom error handler, raise the appropriate exception\nin a test view. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.core.exceptions</span> <span class=\"kn\">import</span> PermissionDenied\n<span class=\"kn\">from</span> <span class=\"nn\">django.http</span> <span class=\"kn\">import</span> HttpResponse\n<span class=\"kn\">from</span> <span class=\"nn\">django.test</span> <span class=\"kn\">import</span> SimpleTestCase<span class=\"p\">,</span> override_settings\n<span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n\n<span class=\"k\">def</span> <span class=\"nf\">response_error_handler</span><span class=\"p\">(</span>request<span class=\"p\">,</span> exception<span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">):</span>\n    <span class=\"k\">return</span> HttpResponse<span class=\"p\">(</span><span class=\"s1\">&#39;Error handler content&#39;</span><span class=\"p\">,</span> status<span class=\"o\">=</span><span class=\"mi\">403</span><span class=\"p\">)</span>\n\n\n<span class=\"k\">def</span> <span class=\"nf\">permission_denied_view</span><span class=\"p\">(</span>request<span class=\"p\">):</span>\n    <span class=\"k\">raise</span> PermissionDenied\n\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span><span class=\"s1\">&#39;403/&#39;</span><span class=\"p\">,</span> permission_denied_view<span class=\"p\">),</span>\n<span class=\"p\">]</span>\n\nhandler403 <span class=\"o\">=</span> response_error_handler\n\n\n<span class=\"c1\"># ROOT_URLCONF must specify the module that contains handler403 = ...</span>\n<span class=\"nd\">@override_settings</span><span class=\"p\">(</span>ROOT_URLCONF<span class=\"o\">=</span><span class=\"vm\">__name__</span><span class=\"p\">)</span>\n<span class=\"k\">class</span> <span class=\"nc\">CustomErrorHandlerTests</span><span class=\"p\">(</span>SimpleTestCase<span class=\"p\">):</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">test_handler_renders_template_response</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        response <span class=\"o\">=</span> <span class=\"bp\">self</span><span class=\"o\">.</span>client<span class=\"o\">.</span>get<span class=\"p\">(</span><span class=\"s1\">&#39;/403/&#39;</span><span class=\"p\">)</span>\n        <span class=\"c1\"># Make assertions on the response here. For example:</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span>assertContains<span class=\"p\">(</span>response<span class=\"p\">,</span> <span class=\"s1\">&#39;Error handler content&#39;</span><span class=\"p\">,</span> status_code<span class=\"o\">=</span><span class=\"mi\">403</span><span class=\"p\">)</span>\n</code></pre></div>\n</section>\n</section>","rootId":"writing-views","toc":[{"title":"Tampilan sederhana","anchor":"a-simple-view","children":[]},{"title":"Memetakan URL ke tampilan","anchor":"mapping-urls-to-views","children":[]},{"title":"Mengembalikan kesalahan","anchor":"returning-errors","children":[{"title":"Pengecualian Http404","anchor":"the-http404-exception","children":[]}]},{"title":"Menyesuaikan tampilan kesalahan","anchor":"customizing-error-views","children":[{"title":"Testing custom error views","anchor":"testing-custom-error-views","children":[]}]}],"breadcrumbs":[{"docname":"topics/index","title":"Menggunakan Django","url":"/id/3.0/topics/"},{"docname":"topics/http/index","title":"Penanganan permintaan HTTP","url":"/id/3.0/topics/http/"}],"prev":{"docname":"topics/http/urls","title":"Pengirim URL","url":"/id/3.0/topics/http/urls/"},"next":{"docname":"topics/http/decorators","title":"View decorators","url":"/id/3.0/topics/http/decorators/"},"formats":{"html":"/id/3.0/topics/http/views/","markdown":"/id/3.0/topics/http/views.md","json":"/id/3.0/topics/http/views.json"},"source":"https://github.com/django/django/blob/stable/3.0.x/docs/topics/http/views.txt","official":"https://docs.djangoproject.com/id/3.0/topics/http/views/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}