{"title":"Mencoba aplikasi GeoDjango","version":"1.11","locale":"id","docname":"ref/contrib/gis/testing","url":"/id/1.11/ref/contrib/gis/testing/","canonical":"https://djangodocs.dev/id/1.11/ref/contrib/gis/testing/","summary":"Included in this documentation are some additional notes and settings for PostGIS users.","html":"<h1>Mencoba aplikasi GeoDjango<a class=\"heading-anchor\" href=\"#testing-geodjango-apps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Included in this documentation are some additional notes and settings\nfor <a class=\"reference internal\" href=\"#testing-postgis\"><span class=\"std std-ref\">PostGIS</span></a> users.</p>\n<section id=\"postgis\">\n<span id=\"testing-postgis\"></span><h2>PostGIS<a class=\"heading-anchor\" href=\"#postgis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"settings\">\n<h3>Pengaturan<a class=\"heading-anchor\" href=\"#settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>The settings below have sensible defaults, and shouldn't require manual setting.</p>\n</aside>\n<section id=\"postgis-version\">\n<span id=\"std-setting-POSTGIS_VERSION\"></span><h4><code class=\"docutils literal notranslate\">POSTGIS_VERSION</code><a class=\"heading-anchor\" href=\"#postgis-version\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>When GeoDjango's spatial backend initializes on PostGIS, it has to perform\nan SQL query to determine the version in order to figure out what\nfeatures are available. Advanced users wishing to prevent this additional\nquery may set the version manually using a 3-tuple of integers specifying\nthe major, minor, and micro version numbers for PostGIS. For example,\nto configure for PostGIS X.Y.Z you would use:</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>POSTGIS_VERSION <span class=\"o\">=</span> <span class=\"p\">(</span>X<span class=\"p\">,</span> Y<span class=\"p\">,</span> Z<span class=\"p\">)</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"obtaining-sufficient-privileges\">\n<h3>Mendapatkan hak cukup<a class=\"heading-anchor\" href=\"#obtaining-sufficient-privileges\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Depending on your configuration, this section describes several methods to\nconfigure a database user with sufficient privileges to run tests for\nGeoDjango applications on PostgreSQL. If your\n<a class=\"reference internal\" href=\"/id/1.11/ref/contrib/gis/install/postgis/#spatialdb-template\"><span class=\"std std-ref\">spatial database template</span></a>\nwas created like in the instructions, then your testing database user\nonly needs to have the ability to create databases. In other configurations,\nyou may be required to use a database superuser.</p>\n<section id=\"create-database-user\">\n<h4>Buat pengguna basisdata<a class=\"heading-anchor\" href=\"#create-database-user\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Untuk membuat pengguna basisdata dengan kemampuan membuat basisdata, gunakan perintah berikut:</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>$ createuser --createdb -R -S &lt;user_name&gt;\n</code></pre></div>\n<p>The <code class=\"docutils literal notranslate\">-R -S</code> flags indicate that we do not want the user to have the ability\nto create additional users (roles) or to be a superuser, respectively.</p>\n<p>Alternatively, you may alter an existing user's role from the SQL shell\n(assuming this is done from an existing superuser account):</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>postgres<span class=\"c1\"># ALTER ROLE &lt;user_name&gt; CREATEDB NOSUPERUSER NOCREATEROLE;</span>\n</code></pre></div>\n</section>\n<section id=\"create-database-superuser\">\n<h4>Membuat basisdata superuser<a class=\"heading-anchor\" href=\"#create-database-superuser\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Ini mungkin selesai pada waktu pengguna dibuat, 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>$ createuser --superuser &lt;user_name&gt;\n</code></pre></div>\n<p>Or you may alter the user's role from the SQL shell (assuming this\nis done from an existing superuser account):</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>postgres<span class=\"c1\"># ALTER ROLE &lt;user_name&gt; SUPERUSER;</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"windows\">\n<h3>Windows<a class=\"heading-anchor\" href=\"#windows\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Pada serambi Windows kegunaan pgAdmin III mungkin juga digunakan sesederhana cara untuk menambahkan hak superuser ke pengguna basisdata anda.</p>\n<p>By default, the PostGIS installer on Windows includes a template\nspatial database entitled <code class=\"docutils literal notranslate\">template_postgis</code>.</p>\n</section>\n</section>\n<section id=\"geodjango-tests\">\n<span id=\"id1\"></span><h2>Percobaan GeoDjango<a class=\"heading-anchor\" href=\"#geodjango-tests\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>To have the GeoDjango tests executed when <a class=\"reference internal\" href=\"/id/1.11/internals/contributing/writing-code/unit-tests/#running-unit-tests\"><span class=\"std std-ref\">running the Django test suite</span></a> with <code class=\"docutils literal notranslate\">runtests.py</code> all of the databases in the settings\nfile must be using one of the <a class=\"reference internal\" href=\"/id/1.11/ref/contrib/gis/db-api/#spatial-backends\"><span class=\"std std-ref\">spatial database backends</span></a>.</p>\n<section id=\"example\">\n<h3>Contoh<a class=\"heading-anchor\" href=\"#example\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The following is an example bare-bones settings file with spatial backends\nthat can be used to run the entire Django test suite, including those\nin <a class=\"reference internal\" href=\"/id/1.11/ref/contrib/gis/#module-django.contrib.gis\" title=\"django.contrib.gis: Geographic Information System (GIS) extensions for Django\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.gis</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>DATABASES <span class=\"o\">=</span> <span class=\"p\">{</span>\n    <span class=\"s1\">&#39;default&#39;</span><span class=\"p\">:</span> <span class=\"p\">{</span>\n        <span class=\"s1\">&#39;ENGINE&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;django.contrib.gis.db.backends.postgis&#39;</span><span class=\"p\">,</span>\n        <span class=\"s1\">&#39;NAME&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;geodjango&#39;</span><span class=\"p\">,</span>\n        <span class=\"s1\">&#39;USER&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;geodjango&#39;</span><span class=\"p\">,</span>\n    <span class=\"p\">},</span>\n    <span class=\"s1\">&#39;other&#39;</span><span class=\"p\">:</span> <span class=\"p\">{</span>\n        <span class=\"s1\">&#39;ENGINE&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;django.contrib.gis.db.backends.postgis&#39;</span><span class=\"p\">,</span>\n        <span class=\"s1\">&#39;NAME&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;other&#39;</span><span class=\"p\">,</span>\n        <span class=\"s1\">&#39;USER&#39;</span><span class=\"p\">:</span> <span class=\"s1\">&#39;geodjango&#39;</span><span class=\"p\">,</span>\n    <span class=\"p\">},</span>\n<span class=\"p\">}</span>\n\nSECRET_KEY <span class=\"o\">=</span> <span class=\"s1\">&#39;django_tests_secret_key&#39;</span>\n</code></pre></div>\n<p>Assuming the settings above were in a <code class=\"docutils literal notranslate\">postgis.py</code> file in the same\ndirectory as <code class=\"docutils literal notranslate\">runtests.py</code>, then all Django and GeoDjango tests would\nbe performed when executing the command:</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>$ ./runtests.py --settings=postgis\n</code></pre></div>\n<p>To run only the GeoDjango test suite, specify <code class=\"docutils literal notranslate\">gis_tests</code>:</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>$ ./runtests.py --settings=postgis gis_tests\n</code></pre></div>\n</section>\n</section>","rootId":"testing-geodjango-apps","toc":[{"title":"PostGIS","anchor":"postgis","children":[{"title":"Pengaturan","anchor":"settings","children":[{"title":"POSTGIS_VERSION","anchor":"postgis-version","children":[]}]},{"title":"Mendapatkan hak cukup","anchor":"obtaining-sufficient-privileges","children":[{"title":"Buat pengguna basisdata","anchor":"create-database-user","children":[]},{"title":"Membuat basisdata superuser","anchor":"create-database-superuser","children":[]}]},{"title":"Windows","anchor":"windows","children":[]}]},{"title":"Percobaan GeoDjango","anchor":"geodjango-tests","children":[{"title":"Contoh","anchor":"example","children":[]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Acuan API","url":"/id/1.11/ref/"},{"docname":"ref/contrib/index","title":"Paket contrib","url":"/id/1.11/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/id/1.11/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/sitemaps","title":"Peta situs Geografis","url":"/id/1.11/ref/contrib/gis/sitemaps/"},"next":{"docname":"ref/contrib/gis/deployment","title":"Menyebarkan GeoDjango","url":"/id/1.11/ref/contrib/gis/deployment/"},"formats":{"html":"/id/1.11/ref/contrib/gis/testing/","markdown":"/id/1.11/ref/contrib/gis/testing.md","json":"/id/1.11/ref/contrib/gis/testing.json"},"source":"https://github.com/django/django/blob/stable/1.11.x/docs/ref/contrib/gis/testing.txt","official":"https://docs.djangoproject.com/id/1.11/ref/contrib/gis/testing/","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","fr","ja","id","pt-br","ko","es","el","pl"]}