{"title":"Model field reference","version":"2.0","locale":"id","docname":"ref/models/fields","url":"/id/2.0/ref/models/fields/","canonical":"https://djangodocs.dev/id/2.0/ref/models/fields/","summary":"This document contains all the API references of Field including the field options and field types Django offers.","html":"<section id=\"module-django.db.models.fields\">\n<span id=\"model-field-reference\"></span><h1>Model field reference<a class=\"heading-anchor\" href=\"#module-django.db.models.fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>This document contains all the API references of <a class=\"reference internal\" href=\"#django.db.models.Field\" title=\"django.db.models.Field\"><code class=\"xref py py-class docutils literal notranslate\">Field</code></a> including the\n<a class=\"reference internal\" href=\"#field-options\">field options</a> and <a class=\"reference internal\" href=\"#field-types\">field types</a> Django offers.</p>\n<aside class=\"admonition admonition-seealso\" role=\"note\">\n<p class=\"admonition-title\">Lihat juga</p>\n<p>If the built-in fields don't do the trick, you can try <a class=\"reference external\" href=\"https://github.com/django/django-localflavor\">django-localflavor</a> (<a class=\"reference external\" href=\"https://django-localflavor.readthedocs.io/\">documentation</a>), which contains assorted\npieces of code that are useful for particular countries and cultures.</p>\n<p>Also, you can easily <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/\"><span class=\"doc\">write your own custom model fields</span></a>.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Technically, these models are defined in <a class=\"reference internal\" href=\"#module-django.db.models.fields\" title=\"django.db.models.fields: Built-in field types.\"><code class=\"xref py py-mod docutils literal notranslate\">django.db.models.fields</code></a>, but\nfor convenience they're imported into <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#module-django.db.models\" title=\"django.db.models\"><code class=\"xref py py-mod docutils literal notranslate\">django.db.models</code></a>; the standard\nconvention is to use <code class=\"docutils literal notranslate\">from django.db import models</code> and refer to fields as\n<code class=\"docutils literal notranslate\">models.&lt;Foo&gt;Field</code>.</p>\n</aside>\n<section id=\"field-options\">\n<span id=\"common-model-field-options\"></span><h2>Pilihan bidang<a class=\"heading-anchor\" href=\"#field-options\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The following arguments are available to all field types. All are optional.</p>\n<section id=\"null\">\n<h3><code class=\"docutils literal notranslate\">null</code><a class=\"heading-anchor\" href=\"#null\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.null\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">null</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.null\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Jika <code class=\"docutils literal notranslate\">True</code>, Django akan menyimpan nilai-nilai kosong sebagai <code class=\"docutils literal notranslate\">NULL</code> di basisdata. Awalan adalah <code class=\"docutils literal notranslate\">False</code>.</p>\n<p>Avoid using <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> on string-based fields such as\n<a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> and <a class=\"reference internal\" href=\"#django.db.models.TextField\" title=\"django.db.models.TextField\"><code class=\"xref py py-class docutils literal notranslate\">TextField</code></a>. If a string-based field has\n<code class=\"docutils literal notranslate\">null=True</code>, that means it has two possible values for &quot;no data&quot;: <code class=\"docutils literal notranslate\">NULL</code>,\nand the empty string. In most cases, it's redundant to have two possible values\nfor &quot;no data;&quot; the Django convention is to use the empty string, not\n<code class=\"docutils literal notranslate\">NULL</code>. One exception is when a <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> has both <code class=\"docutils literal notranslate\">unique=True</code>\nand <code class=\"docutils literal notranslate\">blank=True</code> set. In this situation, <code class=\"docutils literal notranslate\">null=True</code> is required to avoid\nunique constraint violations when saving multiple objects with blank values.</p>\n<p>For both string-based and non-string-based fields, you will also need to\nset <code class=\"docutils literal notranslate\">blank=True</code> if you wish to permit empty values in forms, as the\n<a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> parameter only affects database storage\n(see <a class=\"reference internal\" href=\"#django.db.models.Field.blank\" title=\"django.db.models.Field.blank\"><code class=\"xref py py-attr docutils literal notranslate\">blank</code></a>).</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>When using the Oracle database backend, the value <code class=\"docutils literal notranslate\">NULL</code> will be stored to\ndenote the empty string regardless of this attribute.</p>\n</aside>\n<p>If you want to accept <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> values with <a class=\"reference internal\" href=\"#django.db.models.BooleanField\" title=\"django.db.models.BooleanField\"><code class=\"xref py py-class docutils literal notranslate\">BooleanField</code></a>,\nuse <a class=\"reference internal\" href=\"#django.db.models.NullBooleanField\" title=\"django.db.models.NullBooleanField\"><code class=\"xref py py-class docutils literal notranslate\">NullBooleanField</code></a> instead.</p>\n</section>\n<section id=\"blank\">\n<h3><code class=\"docutils literal notranslate\">blank</code><a class=\"heading-anchor\" href=\"#blank\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.blank\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">blank</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.blank\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Jika <code class=\"docutils literal notranslate\">True</code>, bidang diizinkan menjadi kosong. Awalan adalah <code class=\"docutils literal notranslate\">False</code>.</p>\n<p>Note that this is different than <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a>. <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> is\npurely database-related, whereas <a class=\"reference internal\" href=\"#django.db.models.Field.blank\" title=\"django.db.models.Field.blank\"><code class=\"xref py py-attr docutils literal notranslate\">blank</code></a> is validation-related. If\na field has <code class=\"docutils literal notranslate\">blank=True</code>, form validation will allow entry of an empty value.\nIf a field has <code class=\"docutils literal notranslate\">blank=False</code>, the field will be required.</p>\n</section>\n<section id=\"choices\">\n<span id=\"field-choices\"></span><h3><code class=\"docutils literal notranslate\">choices</code><a class=\"heading-anchor\" href=\"#choices\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.choices\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">choices</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.choices\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>An iterable (e.g., a list or tuple) consisting itself of iterables of exactly\ntwo items (e.g. <code class=\"docutils literal notranslate\">[(A, B), (A, B) ...]</code>) to use as choices for this field. If\nthis is given, the default form widget will be a select box with these choices\ninstead of the standard text field.</p>\n<p>The first element in each tuple is the actual value to be set on the model,\nand the second element is the human-readable name. 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>YEAR_IN_SCHOOL_CHOICES <span class=\"o\">=</span> <span class=\"p\">(</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;FR&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Freshman&#39;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;SO&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Sophomore&#39;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;JR&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Junior&#39;</span><span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;SR&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Senior&#39;</span><span class=\"p\">),</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n<p>Generally, it's best to define choices inside a model class, and to\ndefine a suitably-named constant for each value:</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.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">Student</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    FRESHMAN <span class=\"o\">=</span> <span class=\"s1\">&#39;FR&#39;</span>\n    SOPHOMORE <span class=\"o\">=</span> <span class=\"s1\">&#39;SO&#39;</span>\n    JUNIOR <span class=\"o\">=</span> <span class=\"s1\">&#39;JR&#39;</span>\n    SENIOR <span class=\"o\">=</span> <span class=\"s1\">&#39;SR&#39;</span>\n    YEAR_IN_SCHOOL_CHOICES <span class=\"o\">=</span> <span class=\"p\">(</span>\n        <span class=\"p\">(</span>FRESHMAN<span class=\"p\">,</span> <span class=\"s1\">&#39;Freshman&#39;</span><span class=\"p\">),</span>\n        <span class=\"p\">(</span>SOPHOMORE<span class=\"p\">,</span> <span class=\"s1\">&#39;Sophomore&#39;</span><span class=\"p\">),</span>\n        <span class=\"p\">(</span>JUNIOR<span class=\"p\">,</span> <span class=\"s1\">&#39;Junior&#39;</span><span class=\"p\">),</span>\n        <span class=\"p\">(</span>SENIOR<span class=\"p\">,</span> <span class=\"s1\">&#39;Senior&#39;</span><span class=\"p\">),</span>\n    <span class=\"p\">)</span>\n    year_in_school <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>\n        max_length<span class=\"o\">=</span><span class=\"mi\">2</span><span class=\"p\">,</span>\n        choices<span class=\"o\">=</span>YEAR_IN_SCHOOL_CHOICES<span class=\"p\">,</span>\n        default<span class=\"o\">=</span>FRESHMAN<span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">is_upperclass</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> <span class=\"bp\">self</span><span class=\"o\">.</span>year_in_school <span class=\"ow\">in</span> <span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"o\">.</span>JUNIOR<span class=\"p\">,</span> <span class=\"bp\">self</span><span class=\"o\">.</span>SENIOR<span class=\"p\">)</span>\n</code></pre></div>\n<p>Though you can define a choices list outside of a model class and then\nrefer to it, defining the choices and names for each choice inside the\nmodel class keeps all of that information with the class that uses it,\nand makes the choices easy to reference (e.g, <code class=\"docutils literal notranslate\">Student.SOPHOMORE</code>\nwill work anywhere that the <code class=\"docutils literal notranslate\">Student</code> model has been imported).</p>\n<p>You can also collect your available choices into named groups that can\nbe used for organizational purposes:</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>MEDIA_CHOICES <span class=\"o\">=</span> <span class=\"p\">(</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;Audio&#39;</span><span class=\"p\">,</span> <span class=\"p\">(</span>\n            <span class=\"p\">(</span><span class=\"s1\">&#39;vinyl&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Vinyl&#39;</span><span class=\"p\">),</span>\n            <span class=\"p\">(</span><span class=\"s1\">&#39;cd&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;CD&#39;</span><span class=\"p\">),</span>\n        <span class=\"p\">)</span>\n    <span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;Video&#39;</span><span class=\"p\">,</span> <span class=\"p\">(</span>\n            <span class=\"p\">(</span><span class=\"s1\">&#39;vhs&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;VHS Tape&#39;</span><span class=\"p\">),</span>\n            <span class=\"p\">(</span><span class=\"s1\">&#39;dvd&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;DVD&#39;</span><span class=\"p\">),</span>\n        <span class=\"p\">)</span>\n    <span class=\"p\">),</span>\n    <span class=\"p\">(</span><span class=\"s1\">&#39;unknown&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Unknown&#39;</span><span class=\"p\">),</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n<p>The first element in each tuple is the name to apply to the group. The\nsecond element is an iterable of 2-tuples, with each 2-tuple containing\na value and a human-readable name for an option. Grouped options may be\ncombined with ungrouped options within a single list (such as the\nunknown option in this example).</p>\n<p>For each model field that has <a class=\"reference internal\" href=\"#django.db.models.Field.choices\" title=\"django.db.models.Field.choices\"><code class=\"xref py py-attr docutils literal notranslate\">choices</code></a> set, Django will add a\nmethod to retrieve the human-readable name for the field's current value. See\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model.get_FOO_display\" title=\"django.db.models.Model.get_FOO_display\"><code class=\"xref py py-meth docutils literal notranslate\">get_FOO_display()</code></a> in the database API\ndocumentation.</p>\n<p>Note that choices can be any iterable object -- not necessarily a list or tuple.\nThis lets you construct choices dynamically. But if you find yourself hacking\n<a class=\"reference internal\" href=\"#django.db.models.Field.choices\" title=\"django.db.models.Field.choices\"><code class=\"xref py py-attr docutils literal notranslate\">choices</code></a> to be dynamic, you're probably better off using a proper\ndatabase table with a <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a>. <a class=\"reference internal\" href=\"#django.db.models.Field.choices\" title=\"django.db.models.Field.choices\"><code class=\"xref py py-attr docutils literal notranslate\">choices</code></a> is meant for\nstatic data that doesn't change much, if ever.</p>\n<p>Unless <a class=\"reference internal\" href=\"#django.db.models.Field.blank\" title=\"django.db.models.Field.blank\"><code class=\"xref py py-attr docutils literal notranslate\">blank=False</code></a> is set on the field along with a\n<a class=\"reference internal\" href=\"#django.db.models.Field.default\" title=\"django.db.models.Field.default\"><code class=\"xref py py-attr docutils literal notranslate\">default</code></a> then a label containing <code class=\"docutils literal notranslate\">&quot;---------&quot;</code> will be rendered\nwith the select box. To override this behavior, add a tuple to <code class=\"docutils literal notranslate\">choices</code>\ncontaining <code class=\"docutils literal notranslate\">None</code>; e.g. <code class=\"docutils literal notranslate\">(None, 'Your String For Display')</code>.\nAlternatively, you can use an empty string instead of <code class=\"docutils literal notranslate\">None</code> where this makes\nsense - such as on a <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a>.</p>\n</section>\n<section id=\"db-column\">\n<h3><code class=\"docutils literal notranslate\">db_column</code><a class=\"heading-anchor\" href=\"#db-column\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.db_column\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">db_column</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.db_column\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The name of the database column to use for this field. If this isn't given,\nDjango will use the field's name.</p>\n<p>If your database column name is an SQL reserved word, or contains\ncharacters that aren't allowed in Python variable names -- notably, the\nhyphen -- that's OK. Django quotes column and table names behind the\nscenes.</p>\n</section>\n<section id=\"db-index\">\n<h3><code class=\"docutils literal notranslate\">db_index</code><a class=\"heading-anchor\" href=\"#db-index\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.db_index\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">db_index</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.db_index\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Jika``True``, indeks basisdata akan dibuat untuk bidang ini.</p>\n</section>\n<section id=\"db-tablespace\">\n<h3><code class=\"docutils literal notranslate\">db_tablespace</code><a class=\"heading-anchor\" href=\"#db-tablespace\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.db_tablespace\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">db_tablespace</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.db_tablespace\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The name of the <a class=\"reference internal\" href=\"/id/2.0/topics/db/tablespaces/\"><span class=\"doc\">database tablespace</span></a> to use for\nthis field's index, if this field is indexed. The default is the project's\n<a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-DEFAULT_INDEX_TABLESPACE\"><code class=\"xref std std-setting docutils literal notranslate\">DEFAULT_INDEX_TABLESPACE</code></a> setting, if set, or the\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/options/#django.db.models.Options.db_tablespace\" title=\"django.db.models.Options.db_tablespace\"><code class=\"xref py py-attr docutils literal notranslate\">db_tablespace</code></a> of the model, if any. If the backend doesn't\nsupport tablespaces for indexes, this option is ignored.</p>\n</section>\n<section id=\"default\">\n<h3><code class=\"docutils literal notranslate\">default</code><a class=\"heading-anchor\" href=\"#default\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.default\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">default</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.default\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Nilai awalan untuk bidang. Ini dapat berupa nilai atau obyek callable. Jika callable itu akan dipanggil setiap waktu obyek baru dibuat.</p>\n<p>The default can't be a mutable object (model instance, <code class=\"docutils literal notranslate\">list</code>, <code class=\"docutils literal notranslate\">set</code>, etc.),\nas a reference to the same instance of that object would be used as the default\nvalue in all new model instances. Instead, wrap the desired default in a\ncallable. For example, if you want to specify a default <code class=\"docutils literal notranslate\">dict</code> for\n<a class=\"reference internal\" href=\"/id/2.0/ref/contrib/postgres/fields/#django.contrib.postgres.fields.JSONField\" title=\"django.contrib.postgres.fields.JSONField\"><code class=\"xref py py-class docutils literal notranslate\">JSONField</code></a>, use a function:</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\">def</span> <span class=\"nf\">contact_default</span><span class=\"p\">():</span>\n    <span class=\"k\">return</span> <span class=\"p\">{</span><span class=\"s2\">&quot;email&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;to1@example.com&quot;</span><span class=\"p\">}</span>\n\ncontact_info <span class=\"o\">=</span> JSONField<span class=\"p\">(</span><span class=\"s2\">&quot;ContactInfo&quot;</span><span class=\"p\">,</span> default<span class=\"o\">=</span>contact_default<span class=\"p\">)</span>\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">lambda</code>s can't be used for field options like <code class=\"docutils literal notranslate\">default</code> because they\ncan't be <a class=\"reference internal\" href=\"/id/2.0/topics/migrations/#migration-serializing\"><span class=\"std std-ref\">serialized by migrations</span></a>. See that\ndocumentation for other caveats.</p>\n<p>For fields like <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> that map to model instances, defaults\nshould be the value of the field they reference (<code class=\"docutils literal notranslate\">pk</code> unless\n<a class=\"reference internal\" href=\"#django.db.models.ForeignKey.to_field\" title=\"django.db.models.ForeignKey.to_field\"><code class=\"xref py py-attr docutils literal notranslate\">to_field</code></a> is set) instead of model instances.</p>\n<p>The default value is used when new model instances are created and a value\nisn't provided for the field. When the field is a primary key, the default is\nalso used when the field is set to <code class=\"docutils literal notranslate\">None</code>.</p>\n</section>\n<section id=\"editable\">\n<h3><code class=\"docutils literal notranslate\">editable</code><a class=\"heading-anchor\" href=\"#editable\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.editable\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">editable</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.editable\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>If <code class=\"docutils literal notranslate\">False</code>, the field will not be displayed in the admin or any other\n<a class=\"reference internal\" href=\"/id/2.0/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a>. They are also skipped during <a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#validating-objects\"><span class=\"std std-ref\">model\nvalidation</span></a>. Default is <code class=\"docutils literal notranslate\">True</code>.</p>\n</section>\n<section id=\"error-messages\">\n<h3><code class=\"docutils literal notranslate\">error_messages</code><a class=\"heading-anchor\" href=\"#error-messages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.error_messages\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">error_messages</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.error_messages\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The <code class=\"docutils literal notranslate\">error_messages</code> argument lets you override the default messages that the\nfield will raise. Pass in a dictionary with keys matching the error messages you\nwant to override.</p>\n<p>Error message keys include <code class=\"docutils literal notranslate\">null</code>, <code class=\"docutils literal notranslate\">blank</code>, <code class=\"docutils literal notranslate\">invalid</code>, <code class=\"docutils literal notranslate\">invalid_choice</code>,\n<code class=\"docutils literal notranslate\">unique</code>, and <code class=\"docutils literal notranslate\">unique_for_date</code>. Additional error message keys are\nspecified for each field in the <a class=\"reference internal\" href=\"#field-types\">Field types</a> section below.</p>\n<p>These error messages often don't propagate to forms. See\n<a class=\"reference internal\" href=\"/id/2.0/topics/forms/modelforms/#considerations-regarding-model-errormessages\"><span class=\"std std-ref\">Pertimbangan mengenai error_messages model</span></a>.</p>\n</section>\n<section id=\"help-text\">\n<h3><code class=\"docutils literal notranslate\">help_text</code><a class=\"heading-anchor\" href=\"#help-text\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.help_text\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">help_text</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.help_text\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Teks &quot;help&quot; tambahan untuk ditampilkan dengan widget formulir. Itu sangat berguna untuk dokumentasi bahkan jika bidang anda tidak digunakan pada formulir.</p>\n<p>Note that this value is <em>not</em> HTML-escaped in automatically-generated\nforms. This lets you include HTML in <a class=\"reference internal\" href=\"#django.db.models.Field.help_text\" title=\"django.db.models.Field.help_text\"><code class=\"xref py py-attr docutils literal notranslate\">help_text</code></a> if you so\ndesire. 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>help_text<span class=\"o\">=</span><span class=\"s2\">&quot;Please use the following format: &lt;em&gt;YYYY-MM-DD&lt;/em&gt;.&quot;</span>\n</code></pre></div>\n<p>Alternatively you can use plain text and\n<code class=\"docutils literal notranslate\">django.utils.html.escape()</code> to escape any HTML special characters. Ensure\nthat you escape any help text that may come from untrusted users to avoid a\ncross-site scripting attack.</p>\n</section>\n<section id=\"primary-key\">\n<h3><code class=\"docutils literal notranslate\">primary_key</code><a class=\"heading-anchor\" href=\"#primary-key\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.primary_key\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">primary_key</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.primary_key\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Jika <code class=\"docutils literal notranslate\">True</code>, bidang ini adalah primary key untuk model.</p>\n<p>If you don't specify <code class=\"docutils literal notranslate\">primary_key=True</code> for any field in your model, Django\nwill automatically add an <a class=\"reference internal\" href=\"#django.db.models.AutoField\" title=\"django.db.models.AutoField\"><code class=\"xref py py-class docutils literal notranslate\">AutoField</code></a> to hold the primary key, so you\ndon't need to set <code class=\"docutils literal notranslate\">primary_key=True</code> on any of your fields unless you want to\noverride the default primary-key behavior. For more, see\n<a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#automatic-primary-key-fields\"><span class=\"std std-ref\">Bidang primary key otomatis</span></a>.</p>\n<p><code class=\"docutils literal notranslate\">primary_key=True</code> implies <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null=False</code></a> and\n<a class=\"reference internal\" href=\"#django.db.models.Field.unique\" title=\"django.db.models.Field.unique\"><code class=\"xref py py-attr docutils literal notranslate\">unique=True</code></a>. Only one primary key is allowed on an\nobject.</p>\n<p>The primary key field is read-only. If you change the value of the primary\nkey on an existing object and then save it, a new object will be created\nalongside the old one.</p>\n</section>\n<section id=\"unique\">\n<h3><code class=\"docutils literal notranslate\">unik</code><a class=\"heading-anchor\" href=\"#unique\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.unique\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">unique</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.unique\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Jika <code class=\"docutils literal notranslate\">True</code>, bidang ini harus unik diseluruh tabel.</p>\n<p>This is enforced at the database level and by model validation. If\nyou try to save a model with a duplicate value in a <a class=\"reference internal\" href=\"#django.db.models.Field.unique\" title=\"django.db.models.Field.unique\"><code class=\"xref py py-attr docutils literal notranslate\">unique</code></a>\nfield, a <a class=\"reference internal\" href=\"/id/2.0/ref/exceptions/#django.db.IntegrityError\" title=\"django.db.IntegrityError\"><code class=\"xref py py-exc docutils literal notranslate\">django.db.IntegrityError</code></a> will be raised by the model's\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model.save\" title=\"django.db.models.Model.save\"><code class=\"xref py py-meth docutils literal notranslate\">save()</code></a> method.</p>\n<p>This option is valid on all field types except <a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> and\n<a class=\"reference internal\" href=\"#django.db.models.OneToOneField\" title=\"django.db.models.OneToOneField\"><code class=\"xref py py-class docutils literal notranslate\">OneToOneField</code></a>.</p>\n<p>Note that when <code class=\"docutils literal notranslate\">unique</code> is <code class=\"docutils literal notranslate\">True</code>, you don't need to specify\n<a class=\"reference internal\" href=\"#django.db.models.Field.db_index\" title=\"django.db.models.Field.db_index\"><code class=\"xref py py-attr docutils literal notranslate\">db_index</code></a>, because <code class=\"docutils literal notranslate\">unique</code> implies the creation of an index.</p>\n<aside class=\"version-note version-changed\" data-version=\"1.11\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 1.11</p><p>In older versions, <code class=\"docutils literal notranslate\">unique=True</code> can't be used on <a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a>.</p>\n</aside>\n</section>\n<section id=\"unique-for-date\">\n<h3><code class=\"docutils literal notranslate\">unique_for_date</code><a class=\"heading-anchor\" href=\"#unique-for-date\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.unique_for_date\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">unique_for_date</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.unique_for_date\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Set this to the name of a <a class=\"reference internal\" href=\"#django.db.models.DateField\" title=\"django.db.models.DateField\"><code class=\"xref py py-class docutils literal notranslate\">DateField</code></a> or <a class=\"reference internal\" href=\"#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a> to\nrequire that this field be unique for the value of the date field.</p>\n<p>For example, if you have a field <code class=\"docutils literal notranslate\">title</code> that has\n<code class=\"docutils literal notranslate\">unique_for_date=&quot;pub_date&quot;</code>, then Django wouldn't allow the entry of two\nrecords with the same <code class=\"docutils literal notranslate\">title</code> and <code class=\"docutils literal notranslate\">pub_date</code>.</p>\n<p>Note that if you set this to point to a <a class=\"reference internal\" href=\"#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a>, only the date\nportion of the field will be considered. Besides, when <a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is\n<code class=\"docutils literal notranslate\">True</code>, the check will be performed in the <a class=\"reference internal\" href=\"/id/2.0/topics/i18n/timezones/#default-current-time-zone\"><span class=\"std std-ref\">current time zone</span></a> at the time the object gets saved.</p>\n<p>This is enforced by <a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model.validate_unique\" title=\"django.db.models.Model.validate_unique\"><code class=\"xref py py-meth docutils literal notranslate\">Model.validate_unique()</code></a> during model validation\nbut not at the database level. If any <a class=\"reference internal\" href=\"#django.db.models.Field.unique_for_date\" title=\"django.db.models.Field.unique_for_date\"><code class=\"xref py py-attr docutils literal notranslate\">unique_for_date</code></a> constraint\ninvolves fields that are not part of a <a class=\"reference internal\" href=\"/id/2.0/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a> (for\nexample, if one of the fields is listed in <code class=\"docutils literal notranslate\">exclude</code> or has\n<a class=\"reference internal\" href=\"#django.db.models.Field.editable\" title=\"django.db.models.Field.editable\"><code class=\"xref py py-attr docutils literal notranslate\">editable=False</code></a>), <a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model.validate_unique\" title=\"django.db.models.Model.validate_unique\"><code class=\"xref py py-meth docutils literal notranslate\">Model.validate_unique()</code></a> will\nskip validation for that particular constraint.</p>\n</section>\n<section id=\"unique-for-month\">\n<h3><code class=\"docutils literal notranslate\">unique_for_month</code><a class=\"heading-anchor\" href=\"#unique-for-month\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.unique_for_month\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">unique_for_month</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.unique_for_month\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Like <a class=\"reference internal\" href=\"#django.db.models.Field.unique_for_date\" title=\"django.db.models.Field.unique_for_date\"><code class=\"xref py py-attr docutils literal notranslate\">unique_for_date</code></a>, but requires the field to be unique with\nrespect to the month.</p>\n</section>\n<section id=\"unique-for-year\">\n<h3><code class=\"docutils literal notranslate\">unique_for_year</code><a class=\"heading-anchor\" href=\"#unique-for-year\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.unique_for_year\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">unique_for_year</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.unique_for_year\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Like <a class=\"reference internal\" href=\"#django.db.models.Field.unique_for_date\" title=\"django.db.models.Field.unique_for_date\"><code class=\"xref py py-attr docutils literal notranslate\">unique_for_date</code></a> and <a class=\"reference internal\" href=\"#django.db.models.Field.unique_for_month\" title=\"django.db.models.Field.unique_for_month\"><code class=\"xref py py-attr docutils literal notranslate\">unique_for_month</code></a>.</p>\n</section>\n<section id=\"verbose-name\">\n<h3><code class=\"docutils literal notranslate\">verbose_name</code><a class=\"heading-anchor\" href=\"#verbose-name\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.verbose_name\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">verbose_name</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.verbose_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A human-readable name for the field. If the verbose name isn't given, Django\nwill automatically create it using the field's attribute name, converting\nunderscores to spaces. See <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#verbose-field-names\"><span class=\"std std-ref\">Verbose field names</span></a>.</p>\n</section>\n<section id=\"validators\">\n<h3><code class=\"docutils literal notranslate\">validators</code><a class=\"heading-anchor\" href=\"#validators\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.validators\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">validators</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.validators\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A list of validators to run for this field. See the <a class=\"reference internal\" href=\"/id/2.0/ref/validators/\"><span class=\"doc\">validators\ndocumentation</span></a> for more information.</p>\n<section id=\"registering-and-fetching-lookups\">\n<h4>Registering and fetching lookups<a class=\"heading-anchor\" href=\"#registering-and-fetching-lookups\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><code class=\"docutils literal notranslate\">Field</code> implements the <a class=\"reference internal\" href=\"/id/2.0/ref/models/lookups/#lookup-registration-api\"><span class=\"std std-ref\">lookup registration API</span></a>.\nThe API can be used to customize which lookups are available for a field class, and\nhow lookups are fetched from a field.</p>\n</section>\n</section>\n</section>\n<section id=\"field-types\">\n<span id=\"model-field-types\"></span><h2>Jenis bidang<a class=\"heading-anchor\" href=\"#field-types\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"autofield\">\n<h3><code class=\"docutils literal notranslate\">AutoField</code><a class=\"heading-anchor\" href=\"#autofield\"><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.db.models.AutoField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">AutoField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.AutoField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>An <a class=\"reference internal\" href=\"#django.db.models.IntegerField\" title=\"django.db.models.IntegerField\"><code class=\"xref py py-class docutils literal notranslate\">IntegerField</code></a> that automatically increments\naccording to available IDs. You usually won't need to use this directly; a\nprimary key field will automatically be added to your model if you don't specify\notherwise. See <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#automatic-primary-key-fields\"><span class=\"std std-ref\">Bidang primary key otomatis</span></a>.</p>\n</section>\n<section id=\"bigautofield\">\n<h3><code class=\"docutils literal notranslate\">BigAutoField</code><a class=\"heading-anchor\" href=\"#bigautofield\"><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.db.models.BigAutoField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BigAutoField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.BigAutoField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A 64-bit integer, much like an <a class=\"reference internal\" href=\"#django.db.models.AutoField\" title=\"django.db.models.AutoField\"><code class=\"xref py py-class docutils literal notranslate\">AutoField</code></a> except that it is\nguaranteed to fit numbers from <code class=\"docutils literal notranslate\">1</code> to <code class=\"docutils literal notranslate\">9223372036854775807</code>.</p>\n</section>\n<section id=\"bigintegerfield\">\n<h3><code class=\"docutils literal notranslate\">BigIntegerField</code><a class=\"heading-anchor\" href=\"#bigintegerfield\"><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.db.models.BigIntegerField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BigIntegerField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.BigIntegerField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A 64-bit integer, much like an <a class=\"reference internal\" href=\"#django.db.models.IntegerField\" title=\"django.db.models.IntegerField\"><code class=\"xref py py-class docutils literal notranslate\">IntegerField</code></a> except that it is\nguaranteed to fit numbers from <code class=\"docutils literal notranslate\">-9223372036854775808</code> to\n<code class=\"docutils literal notranslate\">9223372036854775807</code>. The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>.</p>\n</section>\n<section id=\"binaryfield\">\n<h3><code class=\"docutils literal notranslate\">BinaryField</code><a class=\"heading-anchor\" href=\"#binaryfield\"><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.db.models.BinaryField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BinaryField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.BinaryField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A field to store raw binary data. It only supports <code class=\"docutils literal notranslate\">bytes</code> assignment. Be\naware that this field has limited functionality. For example, it is not possible\nto filter a queryset on a <code class=\"docutils literal notranslate\">BinaryField</code> value. It is also not possible to\ninclude a <code class=\"docutils literal notranslate\">BinaryField</code> in a <a class=\"reference internal\" href=\"/id/2.0/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a>.</p>\n<aside class=\"admonition-abusing-binaryfield admonition\" role=\"note\">\n<p class=\"admonition-title\">Menyalahgunakan <code class=\"docutils literal notranslate\">BinaryField</code></p>\n<p>Although you might think about storing files in the database, consider that\nit is bad design in 99% of the cases. This field is <em>not</em> a replacement for\nproper <a class=\"reference internal\" href=\"/id/2.0/howto/static-files/\"><span class=\"doc\">static files</span></a> handling.</p>\n</aside>\n</section>\n<section id=\"booleanfield\">\n<h3><code class=\"docutils literal notranslate\">BooleanField</code><a class=\"heading-anchor\" href=\"#booleanfield\"><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.db.models.BooleanField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BooleanField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.BooleanField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Sebuah bidang true/false.</p>\n<p>The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.CheckboxInput\" title=\"django.forms.CheckboxInput\"><code class=\"xref py py-class docutils literal notranslate\">CheckboxInput</code></a>.</p>\n<p>If you need to accept <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> values then use\n<a class=\"reference internal\" href=\"#django.db.models.NullBooleanField\" title=\"django.db.models.NullBooleanField\"><code class=\"xref py py-class docutils literal notranslate\">NullBooleanField</code></a> instead.</p>\n<p>The default value of <code class=\"docutils literal notranslate\">BooleanField</code> is <code class=\"docutils literal notranslate\">None</code> when <a class=\"reference internal\" href=\"#django.db.models.Field.default\" title=\"django.db.models.Field.default\"><code class=\"xref py py-attr docutils literal notranslate\">Field.default</code></a>\nisn't defined.</p>\n</section>\n<section id=\"charfield\">\n<h3><code class=\"docutils literal notranslate\">CharField</code><a class=\"heading-anchor\" href=\"#charfield\"><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.db.models.CharField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">CharField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.CharField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A string field, for small- to large-sized strings.</p>\n<p>For large amounts of text, use <a class=\"reference internal\" href=\"#django.db.models.TextField\" title=\"django.db.models.TextField\"><code class=\"xref py py-class docutils literal notranslate\">TextField</code></a>.</p>\n<p>The default form widget for this field is a <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>.</p>\n<p><a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> has one extra required argument:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.CharField.max_length\">\n<span class=\"sig-prename descclassname\">CharField.</span><span class=\"sig-name descname\">max_length</span><a class=\"heading-anchor\" href=\"#django.db.models.CharField.max_length\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The maximum length (in characters) of the field. The max_length is enforced\nat the database level and in Django's validation.</p>\n</dd></dl>\n\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>If you are writing an application that must be portable to multiple\ndatabase backends, you should be aware that there are restrictions on\n<code class=\"docutils literal notranslate\">max_length</code> for some backends. Refer to the <a class=\"reference internal\" href=\"/id/2.0/ref/databases/\"><span class=\"doc\">database backend\nnotes</span></a> for details.</p>\n</aside>\n</section>\n<section id=\"datefield\">\n<h3><code class=\"docutils literal notranslate\">DateField</code><a class=\"heading-anchor\" href=\"#datefield\"><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.db.models.DateField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">DateField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">auto_now<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\">auto_now_add<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.DateField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A date, represented in Python by a <code class=\"docutils literal notranslate\">datetime.date</code> instance. Has a few extra,\noptional arguments:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.DateField.auto_now\">\n<span class=\"sig-prename descclassname\">DateField.</span><span class=\"sig-name descname\">auto_now</span><a class=\"heading-anchor\" href=\"#django.db.models.DateField.auto_now\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Automatically set the field to now every time the object is saved. Useful\nfor &quot;last-modified&quot; timestamps. Note that the current date is <em>always</em>\nused; it's not just a default value that you can override.</p>\n<p>The field is only automatically updated when calling <a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model.save\" title=\"django.db.models.Model.save\"><code class=\"xref py py-meth docutils literal notranslate\">Model.save()</code></a>. The field isn't updated when making updates\nto other fields in other ways such as <a class=\"reference internal\" href=\"/id/2.0/ref/models/querysets/#django.db.models.query.QuerySet.update\" title=\"django.db.models.query.QuerySet.update\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.update()</code></a>, though you can specify a custom\nvalue for the field in an update like that.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.DateField.auto_now_add\">\n<span class=\"sig-prename descclassname\">DateField.</span><span class=\"sig-name descname\">auto_now_add</span><a class=\"heading-anchor\" href=\"#django.db.models.DateField.auto_now_add\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Automatically set the field to now when the object is first created. Useful\nfor creation of timestamps. Note that the current date is <em>always</em> used;\nit's not just a default value that you can override. So even if you\nset a value for this field when creating the object, it will be ignored.\nIf you want to be able to modify this field, set the following instead of\n<code class=\"docutils literal notranslate\">auto_now_add=True</code>:</p>\n<ul class=\"simple\">\n<li><p>Untuk <a class=\"reference internal\" href=\"#django.db.models.DateField\" title=\"django.db.models.DateField\"><code class=\"xref py py-class docutils literal notranslate\">DateField</code></a>: <code class=\"docutils literal notranslate\">default=date.today</code> - dari <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date.today\" title=\"(di Python v3.14)\"><code class=\"xref py py-meth docutils literal notranslate\">datetime.date.today()</code></a></p></li>\n<li><p>For <a class=\"reference internal\" href=\"#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a>: <code class=\"docutils literal notranslate\">default=timezone.now</code> - from\n<a class=\"reference internal\" href=\"/id/2.0/ref/utils/#django.utils.timezone.now\" title=\"django.utils.timezone.now\"><code class=\"xref py py-func docutils literal notranslate\">django.utils.timezone.now()</code></a></p></li>\n</ul>\n</dd></dl>\n\n<p>The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>. The admin adds a JavaScript calendar,\nand a shortcut for &quot;Today&quot;. Includes an additional <code class=\"docutils literal notranslate\">invalid_date</code> error\nmessage key.</p>\n<p>The options <code class=\"docutils literal notranslate\">auto_now_add</code>, <code class=\"docutils literal notranslate\">auto_now</code>, and <code class=\"docutils literal notranslate\">default</code> are mutually exclusive.\nAny combination of these options will result in an error.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>As currently implemented, setting <code class=\"docutils literal notranslate\">auto_now</code> or <code class=\"docutils literal notranslate\">auto_now_add</code> to\n<code class=\"docutils literal notranslate\">True</code> will cause the field to have <code class=\"docutils literal notranslate\">editable=False</code> and <code class=\"docutils literal notranslate\">blank=True</code>\nset.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>The <code class=\"docutils literal notranslate\">auto_now</code> and <code class=\"docutils literal notranslate\">auto_now_add</code> options will always use the date in\nthe <a class=\"reference internal\" href=\"/id/2.0/topics/i18n/timezones/#default-current-time-zone\"><span class=\"std std-ref\">default timezone</span></a> at the moment of\ncreation or update. If you need something different, you may want to\nconsider simply using your own callable default or overriding <code class=\"docutils literal notranslate\">save()</code>\ninstead of using <code class=\"docutils literal notranslate\">auto_now</code> or <code class=\"docutils literal notranslate\">auto_now_add</code>; or using a\n<code class=\"docutils literal notranslate\">DateTimeField</code> instead of a <code class=\"docutils literal notranslate\">DateField</code> and deciding how to handle the\nconversion from datetime to date at display time.</p>\n</aside>\n</section>\n<section id=\"datetimefield\">\n<h3><code class=\"docutils literal notranslate\">DateTimeField</code><a class=\"heading-anchor\" href=\"#datetimefield\"><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.db.models.DateTimeField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">DateTimeField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">auto_now<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\">auto_now_add<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.DateTimeField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A date and time, represented in Python by a <code class=\"docutils literal notranslate\">datetime.datetime</code> instance.\nTakes the same extra arguments as <a class=\"reference internal\" href=\"#django.db.models.DateField\" title=\"django.db.models.DateField\"><code class=\"xref py py-class docutils literal notranslate\">DateField</code></a>.</p>\n<p>Widget formulir awal untuk bidang ini adalah tunggal <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>. Admin menggunakan dua widget  <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a> terpisah dengan jalan pintas JavaScript.</p>\n</section>\n<section id=\"decimalfield\">\n<h3><code class=\"docutils literal notranslate\">DecimalField</code><a class=\"heading-anchor\" href=\"#decimalfield\"><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.db.models.DecimalField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">DecimalField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">max_digits<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">decimal_places<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.DecimalField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A fixed-precision decimal number, represented in Python by a\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/decimal.html#decimal.Decimal\" title=\"(di Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">Decimal</code></a> instance. Has two <strong>required</strong> arguments:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.DecimalField.max_digits\">\n<span class=\"sig-prename descclassname\">DecimalField.</span><span class=\"sig-name descname\">max_digits</span><a class=\"heading-anchor\" href=\"#django.db.models.DecimalField.max_digits\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The maximum number of digits allowed in the number. Note that this number\nmust be greater than or equal to <code class=\"docutils literal notranslate\">decimal_places</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.DecimalField.decimal_places\">\n<span class=\"sig-prename descclassname\">DecimalField.</span><span class=\"sig-name descname\">decimal_places</span><a class=\"heading-anchor\" href=\"#django.db.models.DecimalField.decimal_places\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The number of decimal places to store with the number.</p>\n</dd></dl>\n\n<p>For example, to store numbers up to <code class=\"docutils literal notranslate\">999</code> with a resolution of 2 decimal\nplaces, you'd 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>models<span class=\"o\">.</span>DecimalField<span class=\"p\">(</span><span class=\"o\">...</span><span class=\"p\">,</span> max_digits<span class=\"o\">=</span><span class=\"mi\">5</span><span class=\"p\">,</span> decimal_places<span class=\"o\">=</span><span class=\"mi\">2</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>And to store numbers up to approximately one billion with a resolution of 10\ndecimal places:</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>models<span class=\"o\">.</span>DecimalField<span class=\"p\">(</span><span class=\"o\">...</span><span class=\"p\">,</span> max_digits<span class=\"o\">=</span><span class=\"mi\">19</span><span class=\"p\">,</span> decimal_places<span class=\"o\">=</span><span class=\"mi\">10</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>The default form widget for this field is a <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.NumberInput\" title=\"django.forms.NumberInput\"><code class=\"xref py py-class docutils literal notranslate\">NumberInput</code></a>\nwhen <a class=\"reference internal\" href=\"/id/2.0/ref/forms/fields/#django.forms.Field.localize\" title=\"django.forms.Field.localize\"><code class=\"xref py py-attr docutils literal notranslate\">localize</code></a> is <code class=\"docutils literal notranslate\">False</code> or\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a> otherwise.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>For more information about the differences between the\n<a class=\"reference internal\" href=\"#django.db.models.FloatField\" title=\"django.db.models.FloatField\"><code class=\"xref py py-class docutils literal notranslate\">FloatField</code></a> and <a class=\"reference internal\" href=\"#django.db.models.DecimalField\" title=\"django.db.models.DecimalField\"><code class=\"xref py py-class docutils literal notranslate\">DecimalField</code></a> classes, please\nsee <a class=\"reference internal\" href=\"#floatfield-vs-decimalfield\"><span class=\"std std-ref\">FloatField vs. DecimalField</span></a>.</p>\n</aside>\n</section>\n<section id=\"durationfield\">\n<h3><code class=\"docutils literal notranslate\">DurationField</code><a class=\"heading-anchor\" href=\"#durationfield\"><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.db.models.DurationField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">DurationField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.DurationField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A field for storing periods of time - modeled in Python by\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.timedelta\" title=\"(di Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">timedelta</code></a>. When used on PostgreSQL, the data type\nused is an <code class=\"docutils literal notranslate\">interval</code> and on Oracle the data type is <code class=\"docutils literal notranslate\">INTERVAL DAY(9) TO\nSECOND(6)</code>. Otherwise a <code class=\"docutils literal notranslate\">bigint</code> of microseconds is used.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Arithmetic with <code class=\"docutils literal notranslate\">DurationField</code> works in most cases. However on all\ndatabases other than PostgreSQL, comparing the value of a <code class=\"docutils literal notranslate\">DurationField</code>\nto arithmetic on <code class=\"docutils literal notranslate\">DateTimeField</code> instances will not work as expected.</p>\n</aside>\n</section>\n<section id=\"emailfield\">\n<h3><code class=\"docutils literal notranslate\">EmailField</code><a class=\"heading-anchor\" href=\"#emailfield\"><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.db.models.EmailField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">EmailField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">254</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.EmailField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> that checks that the value is a valid email address. It\nuses <a class=\"reference internal\" href=\"/id/2.0/ref/validators/#django.core.validators.EmailValidator\" title=\"django.core.validators.EmailValidator\"><code class=\"xref py py-class docutils literal notranslate\">EmailValidator</code></a> to validate the input.</p>\n</section>\n<section id=\"filefield\">\n<h3><code class=\"docutils literal notranslate\">FileField</code><a class=\"heading-anchor\" href=\"#filefield\"><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.db.models.FileField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">FileField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">upload_to<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">100</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.FileField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Sebuah bidang berkas-unggah</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Argumen <code class=\"docutils literal notranslate\">primary_key</code> tidak didukung dan akan memunculkan sebuah kesalahan jika digunakan.</p>\n</aside>\n<p>Mempunyai dua argumen pilihan:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FileField.upload_to\">\n<span class=\"sig-prename descclassname\">FileField.</span><span class=\"sig-name descname\">upload_to</span><a class=\"heading-anchor\" href=\"#django.db.models.FileField.upload_to\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>This attribute provides a way of setting the upload directory and file name,\nand can be set in two ways. In both cases, the value is passed to the\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage.save\" title=\"django.core.files.storage.Storage.save\"><code class=\"xref py py-meth docutils literal notranslate\">Storage.save()</code></a> method.</p>\n<p>If you specify a string value, it may contain <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strftime\" title=\"(di Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strftime()</code></a>\nformatting, which will be replaced by the date/time of the file upload (so\nthat uploaded files don't fill up the given directory). 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=\"k\">class</span> <span class=\"nc\">MyModel</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    <span class=\"c1\"># file will be uploaded to MEDIA_ROOT/uploads</span>\n    upload <span class=\"o\">=</span> models<span class=\"o\">.</span>FileField<span class=\"p\">(</span>upload_to<span class=\"o\">=</span><span class=\"s1\">&#39;uploads/&#39;</span><span class=\"p\">)</span>\n    <span class=\"c1\"># or...</span>\n    <span class=\"c1\"># file will be saved to MEDIA_ROOT/uploads/2015/01/30</span>\n    upload <span class=\"o\">=</span> models<span class=\"o\">.</span>FileField<span class=\"p\">(</span>upload_to<span class=\"o\">=</span><span class=\"s1\">&#39;uploads/%Y/%m/</span><span class=\"si\">%d</span><span class=\"s1\">/&#39;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>If you are using the default\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.FileSystemStorage\" title=\"django.core.files.storage.FileSystemStorage\"><code class=\"xref py py-class docutils literal notranslate\">FileSystemStorage</code></a>, the string value\nwill be appended to your <a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_ROOT</code></a> path to form the location on\nthe local filesystem where uploaded files will be stored. If you are using\na different storage, check that storage's documentation to see how it\nhandles <code class=\"docutils literal notranslate\">upload_to</code>.</p>\n<p><code class=\"docutils literal notranslate\">upload_to</code> mungkin juga dapat dipanggil, seperti sebuah fungsi. Ini akan dipanggil untuk mendapatkan jalur unggahan, termasuk nama berkas. Panggilan iniharus menerima dua argumen dan mengembalikan jalur gaya-Unix (dengan garis miring didepan) untuk dilewatkan bersama ke sistem penyimpanan. Dua argumen adalah:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Argument</p></th>\n<th class=\"head\"><p>Deskripsi</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p><code class=\"docutils literal notranslate\">instance</code></p></td>\n<td><p>An instance of the model where the\n<code class=\"docutils literal notranslate\">FileField</code> is defined. More specifically,\nthis is the particular instance where the\ncurrent file is being attached.</p>\n<p>Di kebanyakan kasus, obyek ini tidak akan disimpan ke basisdata dulu, jadi jika itu menggunakan <code class=\"docutils literal notranslate\">AutoField</code> awal, <em>itu mungkin belum memiliki nilai untuk bidang primary key nya</em>.</p>\n</td>\n</tr>\n<tr class=\"row-odd\"><td><p><code class=\"docutils literal notranslate\">filename</code></p></td>\n<td><p>The filename that was originally given to the\nfile. This may or may not be taken into account\nwhen determining the final destination path.</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>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=\"k\">def</span> <span class=\"nf\">user_directory_path</span><span class=\"p\">(</span>instance<span class=\"p\">,</span> filename<span class=\"p\">):</span>\n    <span class=\"c1\"># file will be uploaded to MEDIA_ROOT/user_&lt;id&gt;/&lt;filename&gt;</span>\n    <span class=\"k\">return</span> <span class=\"s1\">&#39;user_</span><span class=\"si\">{0}</span><span class=\"s1\">/</span><span class=\"si\">{1}</span><span class=\"s1\">&#39;</span><span class=\"o\">.</span>format<span class=\"p\">(</span>instance<span class=\"o\">.</span>user<span class=\"o\">.</span>id<span class=\"p\">,</span> filename<span class=\"p\">)</span>\n\n<span class=\"k\">class</span> <span class=\"nc\">MyModel</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    upload <span class=\"o\">=</span> models<span class=\"o\">.</span>FileField<span class=\"p\">(</span>upload_to<span class=\"o\">=</span>user_directory_path<span class=\"p\">)</span>\n</code></pre></div>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FileField.storage\">\n<span class=\"sig-prename descclassname\">FileField.</span><span class=\"sig-name descname\">storage</span><a class=\"heading-anchor\" href=\"#django.db.models.FileField.storage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>A storage object, which handles the storage and retrieval of your\nfiles. See <a class=\"reference internal\" href=\"/id/2.0/topics/files/\"><span class=\"doc\">Mengelola berkas</span></a> for details on how to provide this object.</p>\n</dd></dl>\n\n<p>The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.ClearableFileInput\" title=\"django.forms.ClearableFileInput\"><code class=\"xref py py-class docutils literal notranslate\">ClearableFileInput</code></a>.</p>\n<p>Using a <a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a> or an <a class=\"reference internal\" href=\"#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\">ImageField</code></a> (see below) in a model\ntakes a few steps:</p>\n<ol class=\"arabic simple\">\n<li><p>Dalam berkas pengaturan anda, anda akan butuh menentukan <a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_ROOT</code></a> sebagai jalur penuh ke direktori dimana anda ingin menyimpan berkas terunggah. (Untuk penampilan, berkas-berkas ini tidak disimpan di basisdata.) Tentukan <a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_URL</code></a> sebagai dasar URL umum dari direktori itu. pastikan bahwa direktori ini dapat ditulis oleh Jaringan akun pengguna peladen.</p></li>\n<li><p>Add the <a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a> or <a class=\"reference internal\" href=\"#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\">ImageField</code></a> to your model, defining\nthe <a class=\"reference internal\" href=\"#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\">upload_to</code></a> option to specify a subdirectory of\n<a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_ROOT</code></a> to use for uploaded files.</p></li>\n<li><p>All that will be stored in your database is a path to the file\n(relative to <a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_ROOT</code></a>). You'll most likely want to use the\nconvenience <a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile.url\" title=\"django.db.models.fields.files.FieldFile.url\"><code class=\"xref py py-attr docutils literal notranslate\">url</code></a> attribute\nprovided by Django. For example, if your <a class=\"reference internal\" href=\"#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\">ImageField</code></a> is called\n<code class=\"docutils literal notranslate\">mug_shot</code>, you can get the absolute path to your image in a template with\n<code class=\"docutils literal notranslate\">{{ object.mug_shot.url }}</code>.</p></li>\n</ol>\n<p>For example, say your <a class=\"reference internal\" href=\"/id/2.0/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_ROOT</code></a> is set to <code class=\"docutils literal notranslate\">'/home/media'</code>, and\n<a class=\"reference internal\" href=\"#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\">upload_to</code></a> is set to <code class=\"docutils literal notranslate\">'photos/%Y/%m/%d'</code>. The <code class=\"docutils literal notranslate\">'%Y/%m/%d'</code>\npart of <a class=\"reference internal\" href=\"#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\">upload_to</code></a> is <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strftime\" title=\"(di Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strftime()</code></a> formatting;\n<code class=\"docutils literal notranslate\">'%Y'</code> is the four-digit year, <code class=\"docutils literal notranslate\">'%m'</code> is the two-digit month and <code class=\"docutils literal notranslate\">'%d'</code> is\nthe two-digit day. If you upload a file on Jan. 15, 2007, it will be saved in\nthe directory <code class=\"docutils literal notranslate\">/home/media/photos/2007/01/15</code>.</p>\n<p>If you wanted to retrieve the uploaded file's on-disk filename, or the file's\nsize, you could use the <a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File.name\" title=\"django.core.files.File.name\"><code class=\"xref py py-attr docutils literal notranslate\">name</code></a> and\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File.size\" title=\"django.core.files.File.size\"><code class=\"xref py py-attr docutils literal notranslate\">size</code></a> attributes respectively; for more\ninformation on the available attributes and methods, see the\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a> class reference and the <a class=\"reference internal\" href=\"/id/2.0/topics/files/\"><span class=\"doc\">Mengelola berkas</span></a>\ntopic guide.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>Berkas disimpan sebagai bagian dari menyimpan model dalam basisdata, jadi berkas nama sebenarnya digunakan pada cakram tidak dapat bergantung setelah model disimpan.</p>\n</aside>\n<p>The uploaded file's relative URL can be obtained using the\n<a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile.url\" title=\"django.db.models.fields.files.FieldFile.url\"><code class=\"xref py py-attr docutils literal notranslate\">url</code></a> attribute. Internally,\nthis calls the <a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage.url\" title=\"django.core.files.storage.Storage.url\"><code class=\"xref py py-meth docutils literal notranslate\">url()</code></a> method of the\nunderlying <a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage\" title=\"django.core.files.storage.Storage\"><code class=\"xref py py-class docutils literal notranslate\">Storage</code></a> class.</p>\n<p id=\"file-upload-security\">Note that whenever you deal with uploaded files, you should pay close attention\nto where you're uploading them and what type of files they are, to avoid\nsecurity holes. <em>Validate all uploaded files</em> so that you're sure the files are\nwhat you think they are. For example, if you blindly let somebody upload files,\nwithout validation, to a directory that's within your Web server's document\nroot, then somebody could upload a CGI or PHP script and execute that script by\nvisiting its URL on your site. Don't allow that.</p>\n<p>Also note that even an uploaded HTML file, since it can be executed by the\nbrowser (though not by the server), can pose security threats that are\nequivalent to XSS or CSRF attacks.</p>\n<p><a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a> instances are created in your database as <code class=\"docutils literal notranslate\">varchar</code>\ncolumns with a default max length of 100 characters. As with other fields, you\ncan change the maximum length using the <a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> argument.</p>\n<section id=\"filefield-and-fieldfile\">\n<h4><code class=\"docutils literal notranslate\">FileField</code> dan <code class=\"docutils literal notranslate\">FieldFile</code><a class=\"heading-anchor\" href=\"#filefield-and-fieldfile\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">FieldFile</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>When you access a <a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a> on a model, you are\ngiven an instance of <a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile\" title=\"django.db.models.fields.files.FieldFile\"><code class=\"xref py py-class docutils literal notranslate\">FieldFile</code></a> as a proxy for accessing the underlying\nfile.</p>\n<p>The API of <a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile\" title=\"django.db.models.fields.files.FieldFile\"><code class=\"xref py py-class docutils literal notranslate\">FieldFile</code></a> mirrors that of <a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a>,\nwith one key difference: <em>The object wrapped by the class is not necessarily a\nwrapper around Python's built-in file object.</em> Instead, it is a wrapper around\nthe result of the <a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage.open\" title=\"django.core.files.storage.Storage.open\"><code class=\"xref py py-attr docutils literal notranslate\">Storage.open()</code></a>\nmethod, which may be a <a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a> object, or it may be a\ncustom storage's implementation of the <a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a> API.</p>\n<p>In addition to the API inherited from <a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a> such as\n<code class=\"docutils literal notranslate\">read()</code> and <code class=\"docutils literal notranslate\">write()</code>, <a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile\" title=\"django.db.models.fields.files.FieldFile\"><code class=\"xref py py-class docutils literal notranslate\">FieldFile</code></a> includes several methods that\ncan be used to interact with the underlying file:</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Peringatan</p>\n<p>Two methods of this class, <a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile.save\" title=\"django.db.models.fields.files.FieldFile.save\"><code class=\"xref py py-meth docutils literal notranslate\">save()</code></a> and\n<a class=\"reference internal\" href=\"#django.db.models.fields.files.FieldFile.delete\" title=\"django.db.models.fields.files.FieldFile.delete\"><code class=\"xref py py-meth docutils literal notranslate\">delete()</code></a>, default to saving the model object of the\nassociated <code class=\"docutils literal notranslate\">FieldFile</code> in the database.</p>\n</aside>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.name\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">name</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The name of the file including the relative path from the root of the\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage\" title=\"django.core.files.storage.Storage\"><code class=\"xref py py-class docutils literal notranslate\">Storage</code></a> of the associated\n<a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a>.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.size\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">size</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.size\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The result of the underlying <a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage.size\" title=\"django.core.files.storage.Storage.size\"><code class=\"xref py py-attr docutils literal notranslate\">Storage.size()</code></a> method.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.url\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">url</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.url\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A read-only property to access the file's relative URL by calling the\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage.url\" title=\"django.core.files.storage.Storage.url\"><code class=\"xref py py-meth docutils literal notranslate\">url()</code></a> method of the underlying\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/storage/#django.core.files.storage.Storage\" title=\"django.core.files.storage.Storage\"><code class=\"xref py py-class docutils literal notranslate\">Storage</code></a> class.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.open\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">open</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">mode<span class=\"o\">=</span><span class=\"default_value\">'rb'</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.open\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Opens or reopens the file associated with this instance in the specified\n<code class=\"docutils literal notranslate\">mode</code>. Unlike the standard Python <code class=\"docutils literal notranslate\">open()</code> method, it doesn't return a\nfile descriptor.</p>\n<p>Since the underlying file is opened implicitly when accessing it, it may be\nunnecessary to call this method except to reset the pointer to the underlying\nfile or to change the <code class=\"docutils literal notranslate\">mode</code>.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.close\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">close</span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.close\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Behaves like the standard Python <code class=\"docutils literal notranslate\">file.close()</code> method and closes the file\nassociated with this instance.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.save\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">save</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em>, <em class=\"sig-param\">content</em>, <em class=\"sig-param\">save<span class=\"o\">=</span><span class=\"default_value\">True</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.save\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This method takes a filename and file contents and passes them to the storage\nclass for the field, then associates the stored file with the model field.\nIf you want to manually associate file data with\n<a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a> instances on your model, the <code class=\"docutils literal notranslate\">save()</code>\nmethod is used to persist that file data.</p>\n<p>Takes two required arguments: <code class=\"docutils literal notranslate\">name</code> which is the name of the file, and\n<code class=\"docutils literal notranslate\">content</code> which is an object containing the file's contents.  The\noptional <code class=\"docutils literal notranslate\">save</code> argument controls whether or not the model instance is\nsaved after the file associated with this field has been altered. Defaults to\n<code class=\"docutils literal notranslate\">True</code>.</p>\n<p>Note that the <code class=\"docutils literal notranslate\">content</code> argument should be an instance of\n<a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">django.core.files.File</code></a>, not Python's built-in file object.\nYou can construct a <a class=\"reference internal\" href=\"/id/2.0/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a> from an existing\nPython file object like this:</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.files</span> <span class=\"kn\">import</span> File\n<span class=\"c1\"># Open an existing file using Python&#39;s built-in open()</span>\nf <span class=\"o\">=</span> <span class=\"nb\">open</span><span class=\"p\">(</span><span class=\"s1\">&#39;/path/to/hello.world&#39;</span><span class=\"p\">)</span>\nmyfile <span class=\"o\">=</span> File<span class=\"p\">(</span>f<span class=\"p\">)</span>\n</code></pre></div>\n<p>Atau anda dapat membangun satu dari sebush string Python seperti ini:</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.files.base</span> <span class=\"kn\">import</span> ContentFile\nmyfile <span class=\"o\">=</span> ContentFile<span class=\"p\">(</span><span class=\"s2\">&quot;hello world&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Untuk informasi lebih, lihat <a class=\"reference internal\" href=\"/id/2.0/topics/files/\"><span class=\"doc\">Mengelola berkas</span></a>.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.fields.files.FieldFile.delete\">\n<span class=\"sig-prename descclassname\">FieldFile.</span><span class=\"sig-name descname\">delete</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">save<span class=\"o\">=</span><span class=\"default_value\">True</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.fields.files.FieldFile.delete\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Deletes the file associated with this instance and clears all attributes on\nthe field. Note: This method will close the file if it happens to be open when\n<code class=\"docutils literal notranslate\">delete()</code> is called.</p>\n<p>The optional <code class=\"docutils literal notranslate\">save</code> argument controls whether or not the model instance is\nsaved after the file associated with this field has been deleted. Defaults to\n<code class=\"docutils literal notranslate\">True</code>.</p>\n<p>Note that when a model is deleted, related files are not deleted. If you need\nto cleanup orphaned files, you'll need to handle it yourself (for instance,\nwith a custom management command that can be run manually or scheduled to run\nperiodically via e.g. cron).</p>\n</section>\n</section>\n<section id=\"filepathfield\">\n<h3><code class=\"docutils literal notranslate\">FilePathField</code><a class=\"heading-anchor\" href=\"#filepathfield\"><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.db.models.FilePathField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">FilePathField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">path<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">match<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">recursive<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">100</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.FilePathField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> whose choices are limited to the filenames in a certain\ndirectory on the filesystem. Has three special arguments, of which the first is\n<strong>required</strong>:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FilePathField.path\">\n<span class=\"sig-prename descclassname\">FilePathField.</span><span class=\"sig-name descname\">path</span><a class=\"heading-anchor\" href=\"#django.db.models.FilePathField.path\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Required. The absolute filesystem path to a directory from which this\n<a class=\"reference internal\" href=\"#django.db.models.FilePathField\" title=\"django.db.models.FilePathField\"><code class=\"xref py py-class docutils literal notranslate\">FilePathField</code></a> should get its choices. Example: <code class=\"docutils literal notranslate\">&quot;/home/images&quot;</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FilePathField.match\">\n<span class=\"sig-prename descclassname\">FilePathField.</span><span class=\"sig-name descname\">match</span><a class=\"heading-anchor\" href=\"#django.db.models.FilePathField.match\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Optional. A regular expression, as a string, that <a class=\"reference internal\" href=\"#django.db.models.FilePathField\" title=\"django.db.models.FilePathField\"><code class=\"xref py py-class docutils literal notranslate\">FilePathField</code></a>\nwill use to filter filenames. Note that the regex will be applied to the\nbase filename, not the full path. Example: <code class=\"docutils literal notranslate\">&quot;foo.*\\.txt$&quot;</code>, which will\nmatch a file called <code class=\"docutils literal notranslate\">foo23.txt</code> but not <code class=\"docutils literal notranslate\">bar.txt</code> or <code class=\"docutils literal notranslate\">foo23.png</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FilePathField.recursive\">\n<span class=\"sig-prename descclassname\">FilePathField.</span><span class=\"sig-name descname\">recursive</span><a class=\"heading-anchor\" href=\"#django.db.models.FilePathField.recursive\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Optional. Either <code class=\"docutils literal notranslate\">True</code> or <code class=\"docutils literal notranslate\">False</code>. Default is <code class=\"docutils literal notranslate\">False</code>. Specifies\nwhether all subdirectories of <a class=\"reference internal\" href=\"#django.db.models.FilePathField.path\" title=\"django.db.models.FilePathField.path\"><code class=\"xref py py-attr docutils literal notranslate\">path</code></a> should be included</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FilePathField.allow_files\">\n<span class=\"sig-prename descclassname\">FilePathField.</span><span class=\"sig-name descname\">allow_files</span><a class=\"heading-anchor\" href=\"#django.db.models.FilePathField.allow_files\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Optional.  Either <code class=\"docutils literal notranslate\">True</code> or <code class=\"docutils literal notranslate\">False</code>.  Default is <code class=\"docutils literal notranslate\">True</code>.  Specifies\nwhether files in the specified location should be included.  Either this or\n<a class=\"reference internal\" href=\"#django.db.models.FilePathField.allow_folders\" title=\"django.db.models.FilePathField.allow_folders\"><code class=\"xref py py-attr docutils literal notranslate\">allow_folders</code></a> must be <code class=\"docutils literal notranslate\">True</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.FilePathField.allow_folders\">\n<span class=\"sig-prename descclassname\">FilePathField.</span><span class=\"sig-name descname\">allow_folders</span><a class=\"heading-anchor\" href=\"#django.db.models.FilePathField.allow_folders\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Optional.  Either <code class=\"docutils literal notranslate\">True</code> or <code class=\"docutils literal notranslate\">False</code>.  Default is <code class=\"docutils literal notranslate\">False</code>.  Specifies\nwhether folders in the specified location should be included.  Either this\nor <a class=\"reference internal\" href=\"#django.db.models.FilePathField.allow_files\" title=\"django.db.models.FilePathField.allow_files\"><code class=\"xref py py-attr docutils literal notranslate\">allow_files</code></a> must be <code class=\"docutils literal notranslate\">True</code>.</p>\n</dd></dl>\n\n<p>Of course, these arguments can be used together.</p>\n<p>The one potential gotcha is that <a class=\"reference internal\" href=\"#django.db.models.FilePathField.match\" title=\"django.db.models.FilePathField.match\"><code class=\"xref py py-attr docutils literal notranslate\">match</code></a> applies to the\nbase filename, not the full path. So, this 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>FilePathField<span class=\"p\">(</span>path<span class=\"o\">=</span><span class=\"s2\">&quot;/home/images&quot;</span><span class=\"p\">,</span> match<span class=\"o\">=</span><span class=\"s2\">&quot;foo.*&quot;</span><span class=\"p\">,</span> recursive<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>...will match <code class=\"docutils literal notranslate\">/home/images/foo.png</code> but not <code class=\"docutils literal notranslate\">/home/images/foo/bar.png</code>\nbecause the <a class=\"reference internal\" href=\"#django.db.models.FilePathField.match\" title=\"django.db.models.FilePathField.match\"><code class=\"xref py py-attr docutils literal notranslate\">match</code></a> applies to the base filename\n(<code class=\"docutils literal notranslate\">foo.png</code> and <code class=\"docutils literal notranslate\">bar.png</code>).</p>\n<p><a class=\"reference internal\" href=\"#django.db.models.FilePathField\" title=\"django.db.models.FilePathField\"><code class=\"xref py py-class docutils literal notranslate\">FilePathField</code></a> instances are created in your database as <code class=\"docutils literal notranslate\">varchar</code>\ncolumns with a default max length of 100 characters. As with other fields, you\ncan change the maximum length using the <a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> argument.</p>\n</section>\n<section id=\"floatfield\">\n<h3><code class=\"docutils literal notranslate\">FloatField</code><a class=\"heading-anchor\" href=\"#floatfield\"><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.db.models.FloatField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">FloatField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.FloatField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A floating-point number represented in Python by a <code class=\"docutils literal notranslate\">float</code> instance.</p>\n<p>The default form widget for this field is a <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.NumberInput\" title=\"django.forms.NumberInput\"><code class=\"xref py py-class docutils literal notranslate\">NumberInput</code></a>\nwhen <a class=\"reference internal\" href=\"/id/2.0/ref/forms/fields/#django.forms.Field.localize\" title=\"django.forms.Field.localize\"><code class=\"xref py py-attr docutils literal notranslate\">localize</code></a> is <code class=\"docutils literal notranslate\">False</code> or\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a> otherwise.</p>\n<aside class=\"admonition-floatfield-vs-decimalfield admonition\" id=\"floatfield-vs-decimalfield\" role=\"note\">\n<p class=\"admonition-title\"><code class=\"docutils literal notranslate\">FloatField</code> vs. <code class=\"docutils literal notranslate\">DecimalField</code></p>\n<p>The <a class=\"reference internal\" href=\"#django.db.models.FloatField\" title=\"django.db.models.FloatField\"><code class=\"xref py py-class docutils literal notranslate\">FloatField</code></a> class is sometimes mixed up with the\n<a class=\"reference internal\" href=\"#django.db.models.DecimalField\" title=\"django.db.models.DecimalField\"><code class=\"xref py py-class docutils literal notranslate\">DecimalField</code></a> class. Although they both represent real numbers, they\nrepresent those numbers differently. <code class=\"docutils literal notranslate\">FloatField</code> uses Python's <code class=\"docutils literal notranslate\">float</code>\ntype internally, while <code class=\"docutils literal notranslate\">DecimalField</code> uses Python's <code class=\"docutils literal notranslate\">Decimal</code> type. For\ninformation on the difference between the two, see Python's documentation\nfor the <a class=\"reference external\" href=\"https://docs.python.org/3/library/decimal.html#module-decimal\" title=\"(di Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">decimal</code></a> module.</p>\n</aside>\n</section>\n<section id=\"imagefield\">\n<h3><code class=\"docutils literal notranslate\">ImageField</code><a class=\"heading-anchor\" href=\"#imagefield\"><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.db.models.ImageField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">ImageField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">upload_to<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">height_field<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">width_field<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">100</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.ImageField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Inherits all attributes and methods from <a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a>, but also\nvalidates that the uploaded object is a valid image.</p>\n<p>In addition to the special attributes that are available for <a class=\"reference internal\" href=\"#django.db.models.FileField\" title=\"django.db.models.FileField\"><code class=\"xref py py-class docutils literal notranslate\">FileField</code></a>,\nan <a class=\"reference internal\" href=\"#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\">ImageField</code></a> also has <code class=\"docutils literal notranslate\">height</code> and <code class=\"docutils literal notranslate\">width</code> attributes.</p>\n<p>To facilitate querying on those attributes, <a class=\"reference internal\" href=\"#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\">ImageField</code></a> has two extra\noptional arguments:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ImageField.height_field\">\n<span class=\"sig-prename descclassname\">ImageField.</span><span class=\"sig-name descname\">height_field</span><a class=\"heading-anchor\" href=\"#django.db.models.ImageField.height_field\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Name of a model field which will be auto-populated with the height of the\nimage each time the model instance is saved.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ImageField.width_field\">\n<span class=\"sig-prename descclassname\">ImageField.</span><span class=\"sig-name descname\">width_field</span><a class=\"heading-anchor\" href=\"#django.db.models.ImageField.width_field\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Name of a model field which will be auto-populated with the width of the\nimage each time the model instance is saved.</p>\n</dd></dl>\n\n<p>Membutuhkan pustaka <a class=\"reference external\" href=\"https://pillow.readthedocs.io/en/latest/\">Pillow</a></p>\n<p><a class=\"reference internal\" href=\"#django.db.models.ImageField\" title=\"django.db.models.ImageField\"><code class=\"xref py py-class docutils literal notranslate\">ImageField</code></a> instances are created in your database as <code class=\"docutils literal notranslate\">varchar</code>\ncolumns with a default max length of 100 characters. As with other fields, you\ncan change the maximum length using the <a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> argument.</p>\n<p>The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.ClearableFileInput\" title=\"django.forms.ClearableFileInput\"><code class=\"xref py py-class docutils literal notranslate\">ClearableFileInput</code></a>.</p>\n</section>\n<section id=\"integerfield\">\n<h3><code class=\"docutils literal notranslate\">IntegerField</code><a class=\"heading-anchor\" href=\"#integerfield\"><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.db.models.IntegerField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">IntegerField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.IntegerField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>An integer. Values from <code class=\"docutils literal notranslate\">-2147483648</code> to <code class=\"docutils literal notranslate\">2147483647</code> are safe in all\ndatabases supported by Django. The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.NumberInput\" title=\"django.forms.NumberInput\"><code class=\"xref py py-class docutils literal notranslate\">NumberInput</code></a> when <a class=\"reference internal\" href=\"/id/2.0/ref/forms/fields/#django.forms.Field.localize\" title=\"django.forms.Field.localize\"><code class=\"xref py py-attr docutils literal notranslate\">localize</code></a>\nis <code class=\"docutils literal notranslate\">False</code> or <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a> otherwise.</p>\n</section>\n<section id=\"genericipaddressfield\">\n<h3><code class=\"docutils literal notranslate\">GenericIPAddressField</code><a class=\"heading-anchor\" href=\"#genericipaddressfield\"><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.db.models.GenericIPAddressField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">GenericIPAddressField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">protocol<span class=\"o\">=</span><span class=\"default_value\">'both'</span></em>, <em class=\"sig-param\">unpack_ipv4<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.GenericIPAddressField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>An IPv4 or IPv6 address, in string format (e.g. <code class=\"docutils literal notranslate\">192.0.2.30</code> or\n<code class=\"docutils literal notranslate\">2a02:42fe::4</code>). The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>.</p>\n<p>The IPv6 address normalization follows <span class=\"target\" id=\"index-0\"></span><a class=\"rfc reference external\" href=\"https://datatracker.ietf.org/doc/html/rfc4291.html#section-2.2\"><strong>RFC 4291 Section 2.2</strong></a> section 2.2,\nincluding using the IPv4 format suggested in paragraph 3 of that section, like\n<code class=\"docutils literal notranslate\">::ffff:192.0.2.0</code>. For example, <code class=\"docutils literal notranslate\">2001:0::0:01</code> would be normalized to\n<code class=\"docutils literal notranslate\">2001::1</code>, and <code class=\"docutils literal notranslate\">::ffff:0a0a:0a0a</code> to <code class=\"docutils literal notranslate\">::ffff:10.10.10.10</code>. All characters\nare converted to lowercase.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.GenericIPAddressField.protocol\">\n<span class=\"sig-prename descclassname\">GenericIPAddressField.</span><span class=\"sig-name descname\">protocol</span><a class=\"heading-anchor\" href=\"#django.db.models.GenericIPAddressField.protocol\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Limits valid inputs to the specified protocol.\nAccepted values are <code class=\"docutils literal notranslate\">'both'</code> (default), <code class=\"docutils literal notranslate\">'IPv4'</code>\nor <code class=\"docutils literal notranslate\">'IPv6'</code>. Matching is case insensitive.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.GenericIPAddressField.unpack_ipv4\">\n<span class=\"sig-prename descclassname\">GenericIPAddressField.</span><span class=\"sig-name descname\">unpack_ipv4</span><a class=\"heading-anchor\" href=\"#django.db.models.GenericIPAddressField.unpack_ipv4\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Unpacks IPv4 mapped addresses like <code class=\"docutils literal notranslate\">::ffff:192.0.2.1</code>.\nIf this option is enabled that address would be unpacked to\n<code class=\"docutils literal notranslate\">192.0.2.1</code>. Default is disabled. Can only be used\nwhen <code class=\"docutils literal notranslate\">protocol</code> is set to <code class=\"docutils literal notranslate\">'both'</code>.</p>\n</dd></dl>\n\n<p>If you allow for blank values, you have to allow for null values since blank\nvalues are stored as null.</p>\n</section>\n<section id=\"nullbooleanfield\">\n<h3><code class=\"docutils literal notranslate\">NullBooleanField</code><a class=\"heading-anchor\" href=\"#nullbooleanfield\"><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.db.models.NullBooleanField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">NullBooleanField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.NullBooleanField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Like a <a class=\"reference internal\" href=\"#django.db.models.BooleanField\" title=\"django.db.models.BooleanField\"><code class=\"xref py py-class docutils literal notranslate\">BooleanField</code></a>, but allows <code class=\"docutils literal notranslate\">NULL</code> as one of the options. Use\nthis instead of a <a class=\"reference internal\" href=\"#django.db.models.BooleanField\" title=\"django.db.models.BooleanField\"><code class=\"xref py py-class docutils literal notranslate\">BooleanField</code></a> with <code class=\"docutils literal notranslate\">null=True</code>. The default form\nwidget for this field is a <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.NullBooleanSelect\" title=\"django.forms.NullBooleanSelect\"><code class=\"xref py py-class docutils literal notranslate\">NullBooleanSelect</code></a>.</p>\n</section>\n<section id=\"positiveintegerfield\">\n<h3><code class=\"docutils literal notranslate\">PositiveIntegerField</code><a class=\"heading-anchor\" href=\"#positiveintegerfield\"><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.db.models.PositiveIntegerField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">PositiveIntegerField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.PositiveIntegerField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Like an <a class=\"reference internal\" href=\"#django.db.models.IntegerField\" title=\"django.db.models.IntegerField\"><code class=\"xref py py-class docutils literal notranslate\">IntegerField</code></a>, but must be either positive or zero (<code class=\"docutils literal notranslate\">0</code>).\nValues from <code class=\"docutils literal notranslate\">0</code> to <code class=\"docutils literal notranslate\">2147483647</code> are safe in all databases supported by\nDjango. The value <code class=\"docutils literal notranslate\">0</code> is accepted for backward compatibility reasons.</p>\n</section>\n<section id=\"positivesmallintegerfield\">\n<h3><code class=\"docutils literal notranslate\">PositiveSmallIntegerField</code><a class=\"heading-anchor\" href=\"#positivesmallintegerfield\"><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.db.models.PositiveSmallIntegerField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">PositiveSmallIntegerField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.PositiveSmallIntegerField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Like a <a class=\"reference internal\" href=\"#django.db.models.PositiveIntegerField\" title=\"django.db.models.PositiveIntegerField\"><code class=\"xref py py-class docutils literal notranslate\">PositiveIntegerField</code></a>, but only allows values under a certain\n(database-dependent) point. Values from <code class=\"docutils literal notranslate\">0</code> to <code class=\"docutils literal notranslate\">32767</code> are safe in all\ndatabases supported by Django.</p>\n</section>\n<section id=\"slugfield\">\n<h3><code class=\"docutils literal notranslate\">SlugField</code><a class=\"heading-anchor\" href=\"#slugfield\"><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.db.models.SlugField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">SlugField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">50</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.SlugField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p><a class=\"reference internal\" href=\"/id/2.0/glossary/#term-slug\"><span class=\"xref std std-term\">Slug</span></a> is a newspaper term. A slug is a short label for something,\ncontaining only letters, numbers, underscores or hyphens. They're generally used\nin URLs.</p>\n<p>Like a CharField, you can specify <a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> (read the note\nabout database portability and <a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> in that section,\ntoo). If <a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> is not specified, Django will use a\ndefault length of 50.</p>\n<p>menunjuk pengaturan <a class=\"reference internal\" href=\"#django.db.models.Field.db_index\" title=\"django.db.models.Field.db_index\"><code class=\"xref py py-attr docutils literal notranslate\">Field.db_index</code></a> ke <code class=\"docutils literal notranslate\">True</code>.</p>\n<p>Itu sering berguna untuk otomatis mengisi dimuka sebuah SlugField berdasarkan pada nilai dari beberapa nilai lain. Anda dapat melakukan ini otomatis di admin menggunakan <a class=\"reference internal\" href=\"/id/2.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields\" title=\"django.contrib.admin.ModelAdmin.prepopulated_fields\"><code class=\"xref py py-attr docutils literal notranslate\">prepopulated_fields</code></a>.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.SlugField.allow_unicode\">\n<span class=\"sig-prename descclassname\">SlugField.</span><span class=\"sig-name descname\">allow_unicode</span><a class=\"heading-anchor\" href=\"#django.db.models.SlugField.allow_unicode\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>If <code class=\"docutils literal notranslate\">True</code>, the field accepts Unicode letters in addition to ASCII\nletters. Defaults to <code class=\"docutils literal notranslate\">False</code>.</p>\n</dd></dl>\n\n</section>\n<section id=\"smallintegerfield\">\n<h3><code class=\"docutils literal notranslate\">SmallIntegerField</code><a class=\"heading-anchor\" href=\"#smallintegerfield\"><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.db.models.SmallIntegerField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">SmallIntegerField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.SmallIntegerField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Like an <a class=\"reference internal\" href=\"#django.db.models.IntegerField\" title=\"django.db.models.IntegerField\"><code class=\"xref py py-class docutils literal notranslate\">IntegerField</code></a>, but only allows values under a certain\n(database-dependent) point. Values from <code class=\"docutils literal notranslate\">-32768</code> to <code class=\"docutils literal notranslate\">32767</code> are safe in all\ndatabases supported by Django.</p>\n</section>\n<section id=\"textfield\">\n<h3><code class=\"docutils literal notranslate\">TextField</code><a class=\"heading-anchor\" href=\"#textfield\"><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.db.models.TextField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">TextField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.TextField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A large text field. The default form widget for this field is a\n<a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.Textarea\" title=\"django.forms.Textarea\"><code class=\"xref py py-class docutils literal notranslate\">Textarea</code></a>.</p>\n<p>Jika anda menentukan atribut <code class=\"docutils literal notranslate\">max_length</code>, itu akan dipantulkan di widget <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.Textarea\" title=\"django.forms.Textarea\"><code class=\"xref py py-class docutils literal notranslate\">Textarea</code></a> dari bidang formulir dibangkitkan-otomatis. Bagaimanapun itu tidak dipaksa pada model atau tingkatan basisdata. Gunakan <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> untuk itu.</p>\n</section>\n<section id=\"timefield\">\n<h3><code class=\"docutils literal notranslate\">TimeField</code><a class=\"heading-anchor\" href=\"#timefield\"><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.db.models.TimeField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">TimeField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">auto_now<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\">auto_now_add<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.TimeField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A time, represented in Python by a <code class=\"docutils literal notranslate\">datetime.time</code> instance. Accepts the same\nauto-population options as <a class=\"reference internal\" href=\"#django.db.models.DateField\" title=\"django.db.models.DateField\"><code class=\"xref py py-class docutils literal notranslate\">DateField</code></a>.</p>\n<p>The default form widget for this field is a <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>.\nThe admin adds some JavaScript shortcuts.</p>\n</section>\n<section id=\"urlfield\">\n<h3><code class=\"docutils literal notranslate\">URLField</code><a class=\"heading-anchor\" href=\"#urlfield\"><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.db.models.URLField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">URLField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">200</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.URLField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> for a URL.</p>\n<p>The default form widget for this field is a <a class=\"reference internal\" href=\"/id/2.0/ref/forms/widgets/#django.forms.TextInput\" title=\"django.forms.TextInput\"><code class=\"xref py py-class docutils literal notranslate\">TextInput</code></a>.</p>\n<p>Like all <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> subclasses, <a class=\"reference internal\" href=\"#django.db.models.URLField\" title=\"django.db.models.URLField\"><code class=\"xref py py-class docutils literal notranslate\">URLField</code></a> takes the optional\n<a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a> argument. If you don't specify\n<a class=\"reference internal\" href=\"#django.db.models.CharField.max_length\" title=\"django.db.models.CharField.max_length\"><code class=\"xref py py-attr docutils literal notranslate\">max_length</code></a>, a default of 200 is used.</p>\n</section>\n<section id=\"uuidfield\">\n<h3><code class=\"docutils literal notranslate\">UUIDField</code><a class=\"heading-anchor\" href=\"#uuidfield\"><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.db.models.UUIDField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">UUIDField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.UUIDField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A field for storing universally unique identifiers. Uses Python's\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/uuid.html#uuid.UUID\" title=\"(di Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">UUID</code></a> class. When used on PostgreSQL, this stores in a\n<code class=\"docutils literal notranslate\">uuid</code> datatype, otherwise in a <code class=\"docutils literal notranslate\">char(32)</code>.</p>\n<p>Universally unique identifiers are a good alternative to <a class=\"reference internal\" href=\"#django.db.models.AutoField\" title=\"django.db.models.AutoField\"><code class=\"xref py py-class docutils literal notranslate\">AutoField</code></a> for\n<a class=\"reference internal\" href=\"#django.db.models.Field.primary_key\" title=\"django.db.models.Field.primary_key\"><code class=\"xref py py-attr docutils literal notranslate\">primary_key</code></a>. The database will not generate the UUID for you, so\nit is recommended to use <a class=\"reference internal\" href=\"#django.db.models.Field.default\" title=\"django.db.models.Field.default\"><code class=\"xref py py-attr docutils literal notranslate\">default</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><span class=\"kn\">import</span> <span class=\"nn\">uuid</span>\n<span class=\"kn\">from</span> <span class=\"nn\">django.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">MyUUIDModel</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    <span class=\"nb\">id</span> <span class=\"o\">=</span> models<span class=\"o\">.</span>UUIDField<span class=\"p\">(</span>primary_key<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> default<span class=\"o\">=</span>uuid<span class=\"o\">.</span>uuid4<span class=\"p\">,</span> editable<span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">)</span>\n    <span class=\"c1\"># other fields</span>\n</code></pre></div>\n<p>Note that a callable (with the parentheses omitted) is passed to <code class=\"docutils literal notranslate\">default</code>,\nnot an instance of <code class=\"docutils literal notranslate\">UUID</code>.</p>\n</section>\n</section>\n<section id=\"module-django.db.models.fields.related\">\n<span id=\"relationship-fields\"></span><h2>Bidang hubungan<a class=\"heading-anchor\" href=\"#module-django.db.models.fields.related\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django juga menentukan kumpulan bidang yang mewakili hubungan.</p>\n<section id=\"foreignkey\">\n<span id=\"ref-foreignkey\"></span><h3><code class=\"docutils literal notranslate\">ForeignKey</code><a class=\"heading-anchor\" href=\"#foreignkey\"><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.db.models.ForeignKey\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">ForeignKey</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">to</em>, <em class=\"sig-param\">on_delete</em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A many-to-one relationship. Requires two positional arguments: the class to\nwhich the model is related and the <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.on_delete\" title=\"django.db.models.ForeignKey.on_delete\"><code class=\"xref py py-attr docutils literal notranslate\">on_delete</code></a> option.</p>\n<p id=\"recursive-relationships\">To create a recursive relationship -- an object that has a many-to-one\nrelationship with itself -- use <code class=\"docutils literal notranslate\">models.ForeignKey('self',\non_delete=models.CASCADE)</code>.</p>\n<p id=\"lazy-relationships\">If you need to create a relationship on a model that has not yet been defined,\nyou can use the name of the model, rather than the model object itself:</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.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">Car</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    manufacturer <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n        <span class=\"s1\">&#39;Manufacturer&#39;</span><span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n    <span class=\"c1\"># ...</span>\n\n<span class=\"k\">class</span> <span class=\"nc\">Manufacturer</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    <span class=\"c1\"># ...</span>\n    <span class=\"k\">pass</span>\n</code></pre></div>\n<p>Relationships defined this way on <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#abstract-base-classes\"><span class=\"std std-ref\">abstract models</span></a> are resolved when the model is subclassed as a\nconcrete model and are not relative to the abstract model's <code class=\"docutils literal notranslate\">app_label</code>:</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"default\"><figcaption class=\"code-block-caption\"><code>products/models.py</code></figcaption><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=\"products/models.py\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">AbstractCar</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    manufacturer <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span><span class=\"s1\">&#39;Manufacturer&#39;</span><span class=\"p\">,</span> on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">)</span>\n\n    <span class=\"k\">class</span> <span class=\"nc\">Meta</span><span class=\"p\">:</span>\n        abstract <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></figure>\n<figure class=\"code-block code-block-captioned\" data-language=\"default\"><figcaption class=\"code-block-caption\"><code>production/models.py</code></figcaption><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=\"production/models.py\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.db</span> <span class=\"kn\">import</span> models\n<span class=\"kn\">from</span> <span class=\"nn\">products.models</span> <span class=\"kn\">import</span> AbstractCar\n\n<span class=\"k\">class</span> <span class=\"nc\">Manufacturer</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    <span class=\"k\">pass</span>\n\n<span class=\"k\">class</span> <span class=\"nc\">Car</span><span class=\"p\">(</span>AbstractCar<span class=\"p\">):</span>\n    <span class=\"k\">pass</span>\n\n<span class=\"c1\"># Car.manufacturer will point to `production.Manufacturer` here.</span>\n</code></pre></figure>\n<p>To refer to models defined in another application, you can explicitly specify\na model with the full application label. For example, if the <code class=\"docutils literal notranslate\">Manufacturer</code>\nmodel above is defined in another application called <code class=\"docutils literal notranslate\">production</code>, you'd\nneed to 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><span class=\"k\">class</span> <span class=\"nc\">Car</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    manufacturer <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n        <span class=\"s1\">&#39;production.Manufacturer&#39;</span><span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n</code></pre></div>\n<p>This sort of reference, called a lazy relationship, can be useful when\nresolving circular import dependencies between two applications.</p>\n<p>A database index is automatically created on the <code class=\"docutils literal notranslate\">ForeignKey</code>. You can\ndisable this by setting <a class=\"reference internal\" href=\"#django.db.models.Field.db_index\" title=\"django.db.models.Field.db_index\"><code class=\"xref py py-attr docutils literal notranslate\">db_index</code></a> to <code class=\"docutils literal notranslate\">False</code>.  You may want to\navoid the overhead of an index if you are creating a foreign key for\nconsistency rather than joins, or if you will be creating an alternative index\nlike a partial or multiple column index.</p>\n<section id=\"database-representation\">\n<h4>Perwakilan Basisdata<a class=\"heading-anchor\" href=\"#database-representation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Behind the scenes, Django appends <code class=\"docutils literal notranslate\">&quot;_id&quot;</code> to the field name to create its\ndatabase column name. In the above example, the database table for the <code class=\"docutils literal notranslate\">Car</code>\nmodel will have a <code class=\"docutils literal notranslate\">manufacturer_id</code> column. (You can change this explicitly by\nspecifying <a class=\"reference internal\" href=\"#django.db.models.Field.db_column\" title=\"django.db.models.Field.db_column\"><code class=\"xref py py-attr docutils literal notranslate\">db_column</code></a>) However, your code should never have to\ndeal with the database column name, unless you write custom SQL. You'll always\ndeal with the field names of your model object.</p>\n</section>\n<section id=\"arguments\">\n<span id=\"foreign-key-arguments\"></span><h4>Penjelasan<a class=\"heading-anchor\" href=\"#arguments\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> accepts other arguments that define the details of how the\nrelation works.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.on_delete\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">on_delete</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.on_delete\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>When an object referenced by a <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> is deleted, Django will\nemulate the behavior of the SQL constraint specified by the\n<a class=\"reference internal\" href=\"#django.db.models.ForeignKey.on_delete\" title=\"django.db.models.ForeignKey.on_delete\"><code class=\"xref py py-attr docutils literal notranslate\">on_delete</code></a> argument. For example, if you have a nullable\n<a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> and you want it to be set null when the referenced\nobject is deleted:</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>user <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n    User<span class=\"p\">,</span>\n    models<span class=\"o\">.</span>SET_NULL<span class=\"p\">,</span>\n    blank<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span>\n    null<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n</dd></dl>\n\n<p>The possible values for <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.on_delete\" title=\"django.db.models.ForeignKey.on_delete\"><code class=\"xref py py-attr docutils literal notranslate\">on_delete</code></a> are found in\n<a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#module-django.db.models\" title=\"django.db.models\"><code class=\"xref py py-mod docutils literal notranslate\">django.db.models</code></a>:</p>\n<ul>\n<li><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.CASCADE\">\n<span class=\"sig-name descname\">CASCADE</span><a class=\"heading-anchor\" href=\"#django.db.models.CASCADE\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Cascade deletes. Django emulates the behavior of the SQL constraint ON\nDELETE CASCADE and also deletes the object containing the ForeignKey.</p>\n</dd></dl>\n\n</li>\n<li><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.PROTECT\">\n<span class=\"sig-name descname\">PROTECT</span><a class=\"heading-anchor\" href=\"#django.db.models.PROTECT\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Prevent deletion of the referenced object by raising\n<a class=\"reference internal\" href=\"/id/2.0/ref/exceptions/#django.db.models.ProtectedError\" title=\"django.db.models.ProtectedError\"><code class=\"xref py py-exc docutils literal notranslate\">ProtectedError</code></a>, a subclass of\n<a class=\"reference internal\" href=\"/id/2.0/ref/exceptions/#django.db.IntegrityError\" title=\"django.db.IntegrityError\"><code class=\"xref py py-exc docutils literal notranslate\">django.db.IntegrityError</code></a>.</p>\n</dd></dl>\n\n</li>\n<li><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.SET_NULL\">\n<span class=\"sig-name descname\">SET_NULL</span><a class=\"heading-anchor\" href=\"#django.db.models.SET_NULL\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Set the <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> null; this is only possible if\n<a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> is <code class=\"docutils literal notranslate\">True</code>.</p>\n</dd></dl>\n\n</li>\n<li><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.SET_DEFAULT\">\n<span class=\"sig-name descname\">SET_DEFAULT</span><a class=\"heading-anchor\" href=\"#django.db.models.SET_DEFAULT\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Set the <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> to its default value; a default for the\n<a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> must be set.</p>\n</dd></dl>\n\n</li>\n<li><dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.SET\">\n<span class=\"sig-name descname\">SET</span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.SET\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Set the <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> to the value passed to\n<a class=\"reference internal\" href=\"#django.db.models.SET\" title=\"django.db.models.SET\"><code class=\"xref py py-func docutils literal notranslate\">SET()</code></a>, or if a callable is passed in,\nthe result of calling it. In most cases, passing a callable will be\nnecessary to avoid executing queries at the time your models.py is\nimported:</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.conf</span> <span class=\"kn\">import</span> settings\n<span class=\"kn\">from</span> <span class=\"nn\">django.contrib.auth</span> <span class=\"kn\">import</span> get_user_model\n<span class=\"kn\">from</span> <span class=\"nn\">django.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">def</span> <span class=\"nf\">get_sentinel_user</span><span class=\"p\">():</span>\n    <span class=\"k\">return</span> get_user_model<span class=\"p\">()</span><span class=\"o\">.</span>objects<span class=\"o\">.</span>get_or_create<span class=\"p\">(</span>username<span class=\"o\">=</span><span class=\"s1\">&#39;deleted&#39;</span><span class=\"p\">)[</span><span class=\"mi\">0</span><span class=\"p\">]</span>\n\n<span class=\"k\">class</span> <span class=\"nc\">MyModel</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    user <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n        settings<span class=\"o\">.</span>AUTH_USER_MODEL<span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>SET<span class=\"p\">(</span>get_sentinel_user<span class=\"p\">),</span>\n    <span class=\"p\">)</span>\n</code></pre></div>\n</dd></dl>\n\n</li>\n<li><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.DO_NOTHING\">\n<span class=\"sig-name descname\">DO_NOTHING</span><a class=\"heading-anchor\" href=\"#django.db.models.DO_NOTHING\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Take no action. If your database backend enforces referential\nintegrity, this will cause an <a class=\"reference internal\" href=\"/id/2.0/ref/exceptions/#django.db.IntegrityError\" title=\"django.db.IntegrityError\"><code class=\"xref py py-exc docutils literal notranslate\">IntegrityError</code></a> unless\nyou manually add an SQL <code class=\"docutils literal notranslate\">ON DELETE</code> constraint to the database field.</p>\n</dd></dl>\n\n</li>\n</ul>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.limit_choices_to\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">limit_choices_to</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.limit_choices_to\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Sets a limit to the available choices for this field when this field is\nrendered using a <code class=\"docutils literal notranslate\">ModelForm</code> or the admin (by default, all objects\nin the queryset are available to choose). Either a dictionary, a\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/querysets/#django.db.models.Q\" title=\"django.db.models.Q\"><code class=\"xref py py-class docutils literal notranslate\">Q</code></a> object, or a callable returning a\ndictionary or <a class=\"reference internal\" href=\"/id/2.0/ref/models/querysets/#django.db.models.Q\" title=\"django.db.models.Q\"><code class=\"xref py py-class docutils literal notranslate\">Q</code></a> object can be used.</p>\n<p>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>staff_member <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n    User<span class=\"p\">,</span>\n    on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n    limit_choices_to<span class=\"o\">=</span><span class=\"p\">{</span><span class=\"s1\">&#39;is_staff&#39;</span><span class=\"p\">:</span> <span class=\"kc\">True</span><span class=\"p\">},</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n<p>causes the corresponding field on the <code class=\"docutils literal notranslate\">ModelForm</code> to list only <code class=\"docutils literal notranslate\">Users</code>\nthat have <code class=\"docutils literal notranslate\">is_staff=True</code>. This may be helpful in the Django admin.</p>\n<p>The callable form can be helpful, for instance, when used in conjunction\nwith the Python <code class=\"docutils literal notranslate\">datetime</code> module to limit selections by date range. 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=\"k\">def</span> <span class=\"nf\">limit_pub_date_choices</span><span class=\"p\">():</span>\n    <span class=\"k\">return</span> <span class=\"p\">{</span><span class=\"s1\">&#39;pub_date__lte&#39;</span><span class=\"p\">:</span> datetime<span class=\"o\">.</span>date<span class=\"o\">.</span>utcnow<span class=\"p\">()}</span>\n\nlimit_choices_to <span class=\"o\">=</span> limit_pub_date_choices\n</code></pre></div>\n<p>If <code class=\"docutils literal notranslate\">limit_choices_to</code> is or returns a <a class=\"reference internal\" href=\"/id/2.0/ref/models/querysets/#django.db.models.Q\" title=\"django.db.models.Q\"><code class=\"xref py py-class docutils literal notranslate\">Q object</code></a>, which is useful for <a class=\"reference internal\" href=\"/id/2.0/topics/db/queries/#complex-lookups-with-q\"><span class=\"std std-ref\">complex queries</span></a>, then it will only have an effect on the choices\navailable in the admin when the field is not listed in\n<a class=\"reference internal\" href=\"/id/2.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields\" title=\"django.contrib.admin.ModelAdmin.raw_id_fields\"><code class=\"xref py py-attr docutils literal notranslate\">raw_id_fields</code></a> in the\n<code class=\"docutils literal notranslate\">ModelAdmin</code> for the model.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>If a callable is used for <code class=\"docutils literal notranslate\">limit_choices_to</code>, it will be invoked\nevery time a new form is instantiated. It may also be invoked when a\nmodel is validated, for example by management commands or the admin.\nThe admin constructs querysets to validate its form inputs in various\nedge cases multiple times, so there is a possibility your callable may\nbe invoked several times.</p>\n</aside>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.related_name\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">related_name</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.related_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The name to use for the relation from the related object back to this one.\nIt's also the default value for <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.related_query_name\" title=\"django.db.models.ForeignKey.related_query_name\"><code class=\"xref py py-attr docutils literal notranslate\">related_query_name</code></a> (the name to use\nfor the reverse filter name from the target model). See the <a class=\"reference internal\" href=\"/id/2.0/topics/db/queries/#backwards-related-objects\"><span class=\"std std-ref\">related\nobjects documentation</span></a> for a full explanation\nand example. Note that you must set this value when defining relations on\n<a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#abstract-base-classes\"><span class=\"std std-ref\">abstract models</span></a>; and when you do so\n<a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#abstract-related-name\"><span class=\"std std-ref\">some special syntax</span></a> is available.</p>\n<p>If you'd prefer Django not to create a backwards relation, set\n<code class=\"docutils literal notranslate\">related_name</code> to <code class=\"docutils literal notranslate\">'+'</code> or end it with <code class=\"docutils literal notranslate\">'+'</code>. For example, this will\nensure that the <code class=\"docutils literal notranslate\">User</code> model won't have a backwards relation to this\nmodel:</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>user <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n    User<span class=\"p\">,</span>\n    on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n    related_name<span class=\"o\">=</span><span class=\"s1\">&#39;+&#39;</span><span class=\"p\">,</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.related_query_name\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">related_query_name</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.related_query_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The name to use for the reverse filter name from the target model. It\ndefaults to the value of <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.related_name\" title=\"django.db.models.ForeignKey.related_name\"><code class=\"xref py py-attr docutils literal notranslate\">related_name</code></a> or\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/options/#django.db.models.Options.default_related_name\" title=\"django.db.models.Options.default_related_name\"><code class=\"xref py py-attr docutils literal notranslate\">default_related_name</code></a> if set, otherwise it\ndefaults to the name of the model:</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=\"c1\"># Declare the ForeignKey with related_query_name</span>\n<span class=\"k\">class</span> <span class=\"nc\">Tag</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    article <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n        Article<span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n        related_name<span class=\"o\">=</span><span class=\"s2\">&quot;tags&quot;</span><span class=\"p\">,</span>\n        related_query_name<span class=\"o\">=</span><span class=\"s2\">&quot;tag&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n    name <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">255</span><span class=\"p\">)</span>\n\n<span class=\"c1\"># That&#39;s now the name of the reverse filter</span>\nArticle<span class=\"o\">.</span>objects<span class=\"o\">.</span>filter<span class=\"p\">(</span>tag__name<span class=\"o\">=</span><span class=\"s2\">&quot;important&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Like <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.related_name\" title=\"django.db.models.ForeignKey.related_name\"><code class=\"xref py py-attr docutils literal notranslate\">related_name</code></a>, <code class=\"docutils literal notranslate\">related_query_name</code> supports app label and\nclass interpolation via <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#abstract-related-name\"><span class=\"std std-ref\">some special syntax</span></a>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.to_field\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">to_field</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.to_field\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The field on the related object that the relation is to. By default, Django\nuses the primary key of the related object. If you reference a different\nfield, that field must have <code class=\"docutils literal notranslate\">unique=True</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.db_constraint\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">db_constraint</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.db_constraint\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Controls whether or not a constraint should be created in the database for\nthis foreign key. The default is <code class=\"docutils literal notranslate\">True</code>, and that's almost certainly what\nyou want; setting this to <code class=\"docutils literal notranslate\">False</code> can be very bad for data integrity.\nThat said, here are some scenarios where you might want to do this:</p>\n<ul class=\"simple\">\n<li><p>Anda mempunyai warisan data yang tidak sah.</p></li>\n<li><p>You're sharding your database.</p></li>\n</ul>\n<p>If this is set to <code class=\"docutils literal notranslate\">False</code>, accessing a related object that doesn't exist\nwill raise its <code class=\"docutils literal notranslate\">DoesNotExist</code> exception.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ForeignKey.swappable\">\n<span class=\"sig-prename descclassname\">ForeignKey.</span><span class=\"sig-name descname\">swappable</span><a class=\"heading-anchor\" href=\"#django.db.models.ForeignKey.swappable\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Controls the migration framework's reaction if this <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a>\nis pointing at a swappable model. If it is <code class=\"docutils literal notranslate\">True</code> - the default -\nthen if the <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> is pointing at a model which matches\nthe current value of <code class=\"docutils literal notranslate\">settings.AUTH_USER_MODEL</code> (or another swappable\nmodel setting) the relationship will be stored in the migration using\na reference to the setting, not to the model directly.</p>\n<p>You only want to override this to be <code class=\"docutils literal notranslate\">False</code> if you are sure your\nmodel should always point towards the swapped-in model - for example,\nif it is a profile model designed specifically for your custom user model.</p>\n<p>Setting it to <code class=\"docutils literal notranslate\">False</code> does not mean you can reference a swappable model\neven if it is swapped out - <code class=\"docutils literal notranslate\">False</code> just means that the migrations made\nwith this ForeignKey will always reference the exact model you specify\n(so it will fail hard if the user tries to run with a User model you don't\nsupport, for example).</p>\n<p>If in doubt, leave it to its default of <code class=\"docutils literal notranslate\">True</code>.</p>\n</dd></dl>\n\n</section>\n</section>\n<section id=\"manytomanyfield\">\n<h3><code class=\"docutils literal notranslate\">ManyToManyField</code><a class=\"heading-anchor\" href=\"#manytomanyfield\"><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.db.models.ManyToManyField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">ManyToManyField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">to</em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A many-to-many relationship. Requires a positional argument: the class to\nwhich the model is related, which works exactly the same as it does for\n<a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a>, including <a class=\"reference internal\" href=\"#recursive-relationships\"><span class=\"std std-ref\">recursive</span></a> and\n<a class=\"reference internal\" href=\"#lazy-relationships\"><span class=\"std std-ref\">lazy</span></a> relationships.</p>\n<p>Related objects can be added, removed, or created with the field's\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/relations/#django.db.models.fields.related.RelatedManager\" title=\"django.db.models.fields.related.RelatedManager\"><code class=\"xref py py-class docutils literal notranslate\">RelatedManager</code></a>.</p>\n<section id=\"id1\">\n<h4>Perwakilan Basisdata<a class=\"heading-anchor\" href=\"#id1\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Behind the scenes, Django creates an intermediary join table to represent the\nmany-to-many relationship. By default, this table name is generated using the\nname of the many-to-many field and the name of the table for the model that\ncontains it. Since some databases don't support table names above a certain\nlength, these table names will be automatically truncated to 64 characters and a\nuniqueness hash will be used. This means you might see table names like\n<code class=\"docutils literal notranslate\">author_books_9cdf4</code>; this is perfectly normal.  You can manually provide the\nname of the join table using the <a class=\"reference internal\" href=\"#django.db.models.ManyToManyField.db_table\" title=\"django.db.models.ManyToManyField.db_table\"><code class=\"xref py py-attr docutils literal notranslate\">db_table</code></a> option.</p>\n</section>\n<section id=\"manytomany-arguments\">\n<span id=\"id2\"></span><h4>Penjelasan<a class=\"heading-anchor\" href=\"#manytomany-arguments\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> accepts an extra set of arguments -- all optional --\nthat control how the relationship functions.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.related_name\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">related_name</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.related_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Sama seperti <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.related_name\" title=\"django.db.models.ForeignKey.related_name\"><code class=\"xref py py-attr docutils literal notranslate\">ForeignKey.related_name</code></a>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.related_query_name\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">related_query_name</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.related_query_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Sama seperti <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.related_query_name\" title=\"django.db.models.ForeignKey.related_query_name\"><code class=\"xref py py-attr docutils literal notranslate\">ForeignKey.related_query_name</code></a>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.limit_choices_to\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">limit_choices_to</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.limit_choices_to\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Sama seperti <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.limit_choices_to\" title=\"django.db.models.ForeignKey.limit_choices_to\"><code class=\"xref py py-attr docutils literal notranslate\">ForeignKey.limit_choices_to</code></a>.</p>\n<p><code class=\"docutils literal notranslate\">limit_choices_to</code> has no effect when used on a <code class=\"docutils literal notranslate\">ManyToManyField</code> with a\ncustom intermediate table specified using the\n<a class=\"reference internal\" href=\"#django.db.models.ManyToManyField.through\" title=\"django.db.models.ManyToManyField.through\"><code class=\"xref py py-attr docutils literal notranslate\">through</code></a> parameter.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.symmetrical\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">symmetrical</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.symmetrical\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Only used in the definition of ManyToManyFields on self. Consider the\nfollowing model:</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.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">Person</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    friends <span class=\"o\">=</span> models<span class=\"o\">.</span>ManyToManyField<span class=\"p\">(</span><span class=\"s2\">&quot;self&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>When Django processes this model, it identifies that it has a\n<a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> on itself, and as a result, it doesn't add a\n<code class=\"docutils literal notranslate\">person_set</code> attribute to the <code class=\"docutils literal notranslate\">Person</code> class. Instead, the\n<a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> is assumed to be symmetrical -- that is, if I am\nyour friend, then you are my friend.</p>\n<p>If you do not want symmetry in many-to-many relationships with <code class=\"docutils literal notranslate\">self</code>, set\n<a class=\"reference internal\" href=\"#django.db.models.ManyToManyField.symmetrical\" title=\"django.db.models.ManyToManyField.symmetrical\"><code class=\"xref py py-attr docutils literal notranslate\">symmetrical</code></a> to <code class=\"docutils literal notranslate\">False</code>. This will force Django to\nadd the descriptor for the reverse relationship, allowing\n<a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> relationships to be non-symmetrical.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.through\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">through</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.through\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Django will automatically generate a table to manage many-to-many\nrelationships. However, if you want to manually specify the intermediary\ntable, you can use the <a class=\"reference internal\" href=\"#django.db.models.ManyToManyField.through\" title=\"django.db.models.ManyToManyField.through\"><code class=\"xref py py-attr docutils literal notranslate\">through</code></a> option to specify\nthe Django model that represents the intermediate table that you want to\nuse.</p>\n<p>The most common use for this option is when you want to associate\n<a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#intermediary-manytomany\"><span class=\"std std-ref\">extra data with a many-to-many relationship</span></a>.</p>\n<p>If you don't specify an explicit <code class=\"docutils literal notranslate\">through</code> model, there is still an\nimplicit <code class=\"docutils literal notranslate\">through</code> model class you can use to directly access the table\ncreated to hold the association. It has three fields to link the models.</p>\n<p>If the source and target models differ, the following fields are\ngenerated:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">id</code>: the primary key of the relation.</p></li>\n<li><p><code class=\"docutils literal notranslate\">&lt;containing_model&gt;_id</code>: the <code class=\"docutils literal notranslate\">id</code> of the model that declares the\n<code class=\"docutils literal notranslate\">ManyToManyField</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">&lt;other_model&gt;_id</code>: the <code class=\"docutils literal notranslate\">id</code> of the model that the\n<code class=\"docutils literal notranslate\">ManyToManyField</code> points to.</p></li>\n</ul>\n<p>If the <code class=\"docutils literal notranslate\">ManyToManyField</code> points from and to the same model, the following\nfields are generated:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">id</code>: the primary key of the relation.</p></li>\n<li><p><code class=\"docutils literal notranslate\">from_&lt;model&gt;_id</code>: the <code class=\"docutils literal notranslate\">id</code> of the instance which points at the\nmodel (i.e. the source instance).</p></li>\n<li><p><code class=\"docutils literal notranslate\">to_&lt;model&gt;_id</code>: the <code class=\"docutils literal notranslate\">id</code> of the instance to which the relationship\npoints (i.e. the target model instance).</p></li>\n</ul>\n<p>This class can be used to query associated records for a given model\ninstance like a normal model.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.through_fields\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">through_fields</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.through_fields\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Only used when a custom intermediary model is specified. Django will\nnormally determine which fields of the intermediary model to use in order\nto establish a many-to-many relationship automatically. However,\nconsider the following models:</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.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">Person</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    name <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">50</span><span class=\"p\">)</span>\n\n<span class=\"k\">class</span> <span class=\"nc\">Group</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    name <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">128</span><span class=\"p\">)</span>\n    members <span class=\"o\">=</span> models<span class=\"o\">.</span>ManyToManyField<span class=\"p\">(</span>\n        Person<span class=\"p\">,</span>\n        through<span class=\"o\">=</span><span class=\"s1\">&#39;Membership&#39;</span><span class=\"p\">,</span>\n        through_fields<span class=\"o\">=</span><span class=\"p\">(</span><span class=\"s1\">&#39;group&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;person&#39;</span><span class=\"p\">),</span>\n    <span class=\"p\">)</span>\n\n<span class=\"k\">class</span> <span class=\"nc\">Membership</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    group <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>Group<span class=\"p\">,</span> on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">)</span>\n    person <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>Person<span class=\"p\">,</span> on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">)</span>\n    inviter <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>\n        Person<span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n        related_name<span class=\"o\">=</span><span class=\"s2\">&quot;membership_invites&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n    invite_reason <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">64</span><span class=\"p\">)</span>\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">Membership</code> has <em>two</em> foreign keys to <code class=\"docutils literal notranslate\">Person</code> (<code class=\"docutils literal notranslate\">person</code> and\n<code class=\"docutils literal notranslate\">inviter</code>), which makes the relationship ambiguous and Django can't know\nwhich one to use. In this case, you must explicitly specify which\nforeign keys Django should use using <code class=\"docutils literal notranslate\">through_fields</code>, as in the example\nabove.</p>\n<p><code class=\"docutils literal notranslate\">through_fields</code> accepts a 2-tuple <code class=\"docutils literal notranslate\">('field1', 'field2')</code>, where\n<code class=\"docutils literal notranslate\">field1</code> is the name of the foreign key to the model the\n<a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> is defined on (<code class=\"docutils literal notranslate\">group</code> in this case), and\n<code class=\"docutils literal notranslate\">field2</code> the name of the foreign key to the target model (<code class=\"docutils literal notranslate\">person</code>\nin this case).</p>\n<p>When you have more than one foreign key on an intermediary model to any\n(or even both) of the models participating in a many-to-many relationship,\nyou <em>must</em> specify <code class=\"docutils literal notranslate\">through_fields</code>. This also applies to\n<a class=\"reference internal\" href=\"#recursive-relationships\"><span class=\"std std-ref\">recursive relationships</span></a>\nwhen an intermediary model is used and there are more than two\nforeign keys to the model, or you want to explicitly specify which two\nDjango should use.</p>\n<p>Recursive relationships using an intermediary model are always defined as\nnon-symmetrical -- that is, with <a class=\"reference internal\" href=\"#django.db.models.ManyToManyField.symmetrical\" title=\"django.db.models.ManyToManyField.symmetrical\"><code class=\"xref py py-attr docutils literal notranslate\">symmetrical=False</code></a>\n-- therefore, there is the concept of a &quot;source&quot; and a &quot;target&quot;. In that\ncase <code class=\"docutils literal notranslate\">'field1'</code> will be treated as the &quot;source&quot; of the relationship and\n<code class=\"docutils literal notranslate\">'field2'</code> as the &quot;target&quot;.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.db_table\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">db_table</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.db_table\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The name of the table to create for storing the many-to-many data. If this\nis not provided, Django will assume a default name based upon the names of:\nthe table for the model defining the relationship and the name of the field\nitself.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.db_constraint\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">db_constraint</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.db_constraint\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Controls whether or not constraints should be created in the database for\nthe foreign keys in the intermediary table. The default is <code class=\"docutils literal notranslate\">True</code>, and\nthat's almost certainly what you want; setting this to <code class=\"docutils literal notranslate\">False</code> can be\nvery bad for data integrity. That said, here are some scenarios where you\nmight want to do this:</p>\n<ul class=\"simple\">\n<li><p>Anda mempunyai warisan data yang tidak sah.</p></li>\n<li><p>You're sharding your database.</p></li>\n</ul>\n<p>It is an error to pass both <code class=\"docutils literal notranslate\">db_constraint</code> and <code class=\"docutils literal notranslate\">through</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.ManyToManyField.swappable\">\n<span class=\"sig-prename descclassname\">ManyToManyField.</span><span class=\"sig-name descname\">swappable</span><a class=\"heading-anchor\" href=\"#django.db.models.ManyToManyField.swappable\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Controls the migration framework's reaction if this <a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a>\nis pointing at a swappable model. If it is <code class=\"docutils literal notranslate\">True</code> - the default -\nthen if the <a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> is pointing at a model which matches\nthe current value of <code class=\"docutils literal notranslate\">settings.AUTH_USER_MODEL</code> (or another swappable\nmodel setting) the relationship will be stored in the migration using\na reference to the setting, not to the model directly.</p>\n<p>You only want to override this to be <code class=\"docutils literal notranslate\">False</code> if you are sure your\nmodel should always point towards the swapped-in model - for example,\nif it is a profile model designed specifically for your custom user model.</p>\n<p>If in doubt, leave it to its default of <code class=\"docutils literal notranslate\">True</code>.</p>\n</dd></dl>\n\n<p><a class=\"reference internal\" href=\"#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> tidak mendukung <a class=\"reference internal\" href=\"#django.db.models.Field.validators\" title=\"django.db.models.Field.validators\"><code class=\"xref py py-attr docutils literal notranslate\">validators</code></a>.</p>\n<p><a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> has no effect since there is no way to require a\nrelationship at the database level.</p>\n</section>\n</section>\n<section id=\"onetoonefield\">\n<h3><code class=\"docutils literal notranslate\">OneToOneField</code><a class=\"heading-anchor\" href=\"#onetoonefield\"><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.db.models.OneToOneField\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">OneToOneField</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">to</em>, <em class=\"sig-param\">on_delete</em>, <em class=\"sig-param\">parent_link<span class=\"o\">=</span><span class=\"default_value\">False</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.OneToOneField\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A one-to-one relationship. Conceptually, this is similar to a\n<a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> with <a class=\"reference internal\" href=\"#django.db.models.Field.unique\" title=\"django.db.models.Field.unique\"><code class=\"xref py py-attr docutils literal notranslate\">unique=True</code></a>, but the\n&quot;reverse&quot; side of the relation will directly return a single object.</p>\n<p>This is most useful as the primary key of a model which &quot;extends&quot;\nanother model in some way; <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/#multi-table-inheritance\"><span class=\"std std-ref\">Warisan banyak-tabel</span></a> is\nimplemented by adding an implicit one-to-one relation from the child\nmodel to the parent model, for example.</p>\n<p>One positional argument is required: the class to which the model will be\nrelated. This works exactly the same as it does for <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a>,\nincluding all the options regarding <a class=\"reference internal\" href=\"#recursive-relationships\"><span class=\"std std-ref\">recursive</span></a>\nand <a class=\"reference internal\" href=\"#lazy-relationships\"><span class=\"std std-ref\">lazy</span></a> relationships.</p>\n<p>If you do not specify the <a class=\"reference internal\" href=\"#django.db.models.ForeignKey.related_name\" title=\"django.db.models.ForeignKey.related_name\"><code class=\"xref py py-attr docutils literal notranslate\">related_name</code></a> argument for\nthe <code class=\"docutils literal notranslate\">OneToOneField</code>, Django will use the lower-case name of the current model\nas default value.</p>\n<p>Dengan contoh 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><span class=\"kn\">from</span> <span class=\"nn\">django.conf</span> <span class=\"kn\">import</span> settings\n<span class=\"kn\">from</span> <span class=\"nn\">django.db</span> <span class=\"kn\">import</span> models\n\n<span class=\"k\">class</span> <span class=\"nc\">MySpecialUser</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    user <span class=\"o\">=</span> models<span class=\"o\">.</span>OneToOneField<span class=\"p\">(</span>\n        settings<span class=\"o\">.</span>AUTH_USER_MODEL<span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n    supervisor <span class=\"o\">=</span> models<span class=\"o\">.</span>OneToOneField<span class=\"p\">(</span>\n        settings<span class=\"o\">.</span>AUTH_USER_MODEL<span class=\"p\">,</span>\n        on_delete<span class=\"o\">=</span>models<span class=\"o\">.</span>CASCADE<span class=\"p\">,</span>\n        related_name<span class=\"o\">=</span><span class=\"s1\">&#39;supervisor_of&#39;</span><span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n</code></pre></div>\n<p>your resulting <code class=\"docutils literal notranslate\">User</code> model will have the following attributes:</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=\"gp\">&gt;&gt;&gt; </span>user <span class=\"o\">=</span> User<span class=\"o\">.</span>objects<span class=\"o\">.</span>get<span class=\"p\">(</span>pk<span class=\"o\">=</span><span class=\"mi\">1</span><span class=\"p\">)</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"nb\">hasattr</span><span class=\"p\">(</span>user<span class=\"p\">,</span> <span class=\"s1\">&#39;myspecialuser&#39;</span><span class=\"p\">)</span>\n<span class=\"go\">True</span>\n<span class=\"gp\">&gt;&gt;&gt; </span><span class=\"nb\">hasattr</span><span class=\"p\">(</span>user<span class=\"p\">,</span> <span class=\"s1\">&#39;supervisor_of&#39;</span><span class=\"p\">)</span>\n<span class=\"go\">True</span>\n</code></pre></div>\n<p>A <code class=\"docutils literal notranslate\">DoesNotExist</code> exception is raised when accessing the reverse relationship\nif an entry in the related table doesn't exist. For example, if a user doesn't\nhave a supervisor designated by <code class=\"docutils literal notranslate\">MySpecialUser</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><span class=\"gp\">&gt;&gt;&gt; </span>user<span class=\"o\">.</span>supervisor_of\n<span class=\"gt\">Traceback (most recent call last):</span>\n    <span class=\"o\">...</span>\n<span class=\"gr\">DoesNotExist</span>: User matching query does not exist.\n</code></pre></div>\n<p id=\"onetoone-arguments\">Additionally, <code class=\"docutils literal notranslate\">OneToOneField</code> accepts all of the extra arguments\naccepted by <a class=\"reference internal\" href=\"#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a>, plus one extra argument:</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.OneToOneField.parent_link\">\n<span class=\"sig-prename descclassname\">OneToOneField.</span><span class=\"sig-name descname\">parent_link</span><a class=\"heading-anchor\" href=\"#django.db.models.OneToOneField.parent_link\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>When <code class=\"docutils literal notranslate\">True</code> and used in a model which inherits from another\n<a class=\"reference internal\" href=\"/id/2.0/glossary/#term-concrete-model\"><span class=\"xref std std-term\">concrete model</span></a>, indicates that this field should be used as the\nlink back to the parent class, rather than the extra\n<code class=\"docutils literal notranslate\">OneToOneField</code> which would normally be implicitly created by\nsubclassing.</p>\n</dd></dl>\n\n<p>See <a class=\"reference internal\" href=\"/id/2.0/topics/db/examples/one_to_one/\"><span class=\"doc\">One-to-one relationships</span></a> for usage\nexamples of <code class=\"docutils literal notranslate\">OneToOneField</code>.</p>\n</section>\n</section>\n<section id=\"field-api-reference\">\n<h2>Field API reference<a class=\"heading-anchor\" href=\"#field-api-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">Field</span><a class=\"heading-anchor\" href=\"#django.db.models.Field\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p><code class=\"docutils literal notranslate\">Field</code> is an abstract class that represents a database table column.\nDjango uses fields to create the database table (<a class=\"reference internal\" href=\"#django.db.models.Field.db_type\" title=\"django.db.models.Field.db_type\"><code class=\"xref py py-meth docutils literal notranslate\">db_type()</code></a>), to map\nPython types to database (<a class=\"reference internal\" href=\"#django.db.models.Field.get_prep_value\" title=\"django.db.models.Field.get_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_prep_value()</code></a>) and vice-versa\n(<a class=\"reference internal\" href=\"#django.db.models.Field.from_db_value\" title=\"django.db.models.Field.from_db_value\"><code class=\"xref py py-meth docutils literal notranslate\">from_db_value()</code></a>).</p>\n<p>A field is thus a fundamental piece in different Django APIs, notably,\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model\" title=\"django.db.models.Model\"><code class=\"xref py py-class docutils literal notranslate\">models</code></a> and <a class=\"reference internal\" href=\"/id/2.0/ref/models/querysets/#django.db.models.query.QuerySet\" title=\"django.db.models.query.QuerySet\"><code class=\"xref py py-class docutils literal notranslate\">querysets</code></a>.</p>\n<p>In models, a field is instantiated as a class attribute and represents a\nparticular table column, see <a class=\"reference internal\" href=\"/id/2.0/topics/db/models/\"><span class=\"doc\">Model</span></a>. It has attributes\nsuch as <a class=\"reference internal\" href=\"#django.db.models.Field.null\" title=\"django.db.models.Field.null\"><code class=\"xref py py-attr docutils literal notranslate\">null</code></a> and <a class=\"reference internal\" href=\"#django.db.models.Field.unique\" title=\"django.db.models.Field.unique\"><code class=\"xref py py-attr docutils literal notranslate\">unique</code></a>, and methods that Django uses to\nmap the field value to database-specific values.</p>\n<p>A <code class=\"docutils literal notranslate\">Field</code> is a subclass of\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/lookups/#django.db.models.lookups.RegisterLookupMixin\" title=\"django.db.models.lookups.RegisterLookupMixin\"><code class=\"xref py py-class docutils literal notranslate\">RegisterLookupMixin</code></a> and thus both\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/lookups/#django.db.models.Transform\" title=\"django.db.models.Transform\"><code class=\"xref py py-class docutils literal notranslate\">Transform</code></a> and\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/lookups/#django.db.models.Lookup\" title=\"django.db.models.Lookup\"><code class=\"xref py py-class docutils literal notranslate\">Lookup</code></a> can be registered on it to be used\nin <code class=\"docutils literal notranslate\">QuerySet</code>s (e.g. <code class=\"docutils literal notranslate\">field_name__exact=&quot;foo&quot;</code>). All <a class=\"reference internal\" href=\"/id/2.0/ref/models/querysets/#field-lookups\"><span class=\"std std-ref\">built-in\nlookups</span></a> are registered by default.</p>\n<p>All of Django's built-in fields, such as <a class=\"reference internal\" href=\"#django.db.models.CharField\" title=\"django.db.models.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a>, are particular\nimplementations of <code class=\"docutils literal notranslate\">Field</code>. If you need a custom field, you can either\nsubclass any of the built-in fields or write a <code class=\"docutils literal notranslate\">Field</code> from scratch. In\neither case, see <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/\"><span class=\"doc\">Menulis bidang model penyesuaian</span></a>.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.description\">\n<span class=\"sig-name descname\">description</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.description\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>A verbose description of the field, e.g. for the\n<a class=\"reference internal\" href=\"/id/2.0/ref/contrib/admin/admindocs/#module-django.contrib.admindocs\" title=\"django.contrib.admindocs: Django's admin documentation generator.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.admindocs</code></a> application.</p>\n<p>The description can be of the form:</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>description <span class=\"o\">=</span> _<span class=\"p\">(</span><span class=\"s2\">&quot;String (up to </span><span class=\"si\">%(max_length)s</span><span class=\"s2\">)&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>where the arguments are interpolated from the field's <code class=\"docutils literal notranslate\">__dict__</code>.</p>\n</dd></dl>\n\n<p>To map a <code class=\"docutils literal notranslate\">Field</code> to a database-specific type, Django exposes several\nmethods:</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.get_internal_type\">\n<span class=\"sig-name descname\">get_internal_type</span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.get_internal_type\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a string naming this field for backend specific purposes.\nBy default, it returns the class name.</p>\n<p>See <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#emulating-built-in-field-types\"><span class=\"std std-ref\">Menyamai jenis bidang siap pakai</span></a> for usage in custom fields.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.db_type\">\n<span class=\"sig-name descname\">db_type</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">connection</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.db_type\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the database column data type for the <a class=\"reference internal\" href=\"#django.db.models.Field\" title=\"django.db.models.Field\"><code class=\"xref py py-class docutils literal notranslate\">Field</code></a>, taking\ninto account the <code class=\"docutils literal notranslate\">connection</code>.</p>\n<p>See <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#custom-database-types\"><span class=\"std std-ref\">Jenis basisdata penyesuaian</span></a> for usage in custom fields.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.rel_db_type\">\n<span class=\"sig-name descname\">rel_db_type</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">connection</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.rel_db_type\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the database column data type for fields such as <code class=\"docutils literal notranslate\">ForeignKey</code>\nand <code class=\"docutils literal notranslate\">OneToOneField</code> that point to the <a class=\"reference internal\" href=\"#django.db.models.Field\" title=\"django.db.models.Field\"><code class=\"xref py py-class docutils literal notranslate\">Field</code></a>, taking\ninto account the <code class=\"docutils literal notranslate\">connection</code>.</p>\n<p>See <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#custom-database-types\"><span class=\"std std-ref\">Jenis basisdata penyesuaian</span></a> for usage in custom fields.</p>\n</dd></dl>\n\n<p>There are three main situations where Django needs to interact with the\ndatabase backend and fields:</p>\n<ul class=\"simple\">\n<li><p>when it queries the database (Python value -&gt; database backend value)</p></li>\n<li><p>when it loads data from the database (database backend value -&gt; Python\nvalue)</p></li>\n<li><p>when it saves to the database (Python value -&gt; database backend value)</p></li>\n</ul>\n<p>When querying, <a class=\"reference internal\" href=\"#django.db.models.Field.get_db_prep_value\" title=\"django.db.models.Field.get_db_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_db_prep_value()</code></a> and <a class=\"reference internal\" href=\"#django.db.models.Field.get_prep_value\" title=\"django.db.models.Field.get_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_prep_value()</code></a> are used:</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.get_prep_value\">\n<span class=\"sig-name descname\">get_prep_value</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">value</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.get_prep_value\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p><code class=\"docutils literal notranslate\">value</code> is the current value of the model's attribute, and the method\nshould return data in a format that has been prepared for use as a\nparameter in a query.</p>\n<p>See <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#converting-python-objects-to-query-values\"><span class=\"std std-ref\">Mengubah obyek Python ke nilai pencarian</span></a> for usage.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.get_db_prep_value\">\n<span class=\"sig-name descname\">get_db_prep_value</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">value</em>, <em class=\"sig-param\">connection</em>, <em class=\"sig-param\">prepared<span class=\"o\">=</span><span class=\"default_value\">False</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.get_db_prep_value\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Converts <code class=\"docutils literal notranslate\">value</code> to a backend-specific value. By default it returns\n<code class=\"docutils literal notranslate\">value</code> if <code class=\"docutils literal notranslate\">prepared=True</code> and <a class=\"reference internal\" href=\"#django.db.models.Field.get_prep_value\" title=\"django.db.models.Field.get_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_prep_value()</code></a> if is\n<code class=\"docutils literal notranslate\">False</code>.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#converting-query-values-to-database-values\"><span class=\"std std-ref\">Mengubah nilai pencarian ke nilai basisdata</span></a> untuk penggunaan.</p>\n</dd></dl>\n\n<p>Ketika memuat data, <a class=\"reference internal\" href=\"#django.db.models.Field.from_db_value\" title=\"django.db.models.Field.from_db_value\"><code class=\"xref py py-meth docutils literal notranslate\">from_db_value()</code></a> digunakan:</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.from_db_value\">\n<span class=\"sig-name descname\">from_db_value</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">value</em>, <em class=\"sig-param\">expression</em>, <em class=\"sig-param\">connection</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.from_db_value\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Converts a value as returned by the database to a Python object. It is\nthe reverse of <a class=\"reference internal\" href=\"#django.db.models.Field.get_prep_value\" title=\"django.db.models.Field.get_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_prep_value()</code></a>.</p>\n<p>This method is not used for most built-in fields as the database\nbackend already returns the correct Python type, or the backend itself\ndoes the conversion.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#converting-values-to-python-objects\"><span class=\"std std-ref\">Mengubah nilai menjadi obyek Python</span></a> untuk penggunaan.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p>For performance reasons, <code class=\"docutils literal notranslate\">from_db_value</code> is not implemented as a\nno-op on fields which do not require it (all Django fields).\nConsequently you may not call <code class=\"docutils literal notranslate\">super</code> in your definition.</p>\n</aside>\n</dd></dl>\n\n<p>Ketika menyimpan,  <a class=\"reference internal\" href=\"#django.db.models.Field.pre_save\" title=\"django.db.models.Field.pre_save\"><code class=\"xref py py-meth docutils literal notranslate\">pre_save()</code></a> dan <a class=\"reference internal\" href=\"#django.db.models.Field.get_db_prep_save\" title=\"django.db.models.Field.get_db_prep_save\"><code class=\"xref py py-meth docutils literal notranslate\">get_db_prep_save()</code></a> digunakan:</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.get_db_prep_save\">\n<span class=\"sig-name descname\">get_db_prep_save</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">value</em>, <em class=\"sig-param\">connection</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.get_db_prep_save\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Same as the <a class=\"reference internal\" href=\"#django.db.models.Field.get_db_prep_value\" title=\"django.db.models.Field.get_db_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_db_prep_value()</code></a>, but called when the field value\nmust be <em>saved</em> to the database. By default returns\n<a class=\"reference internal\" href=\"#django.db.models.Field.get_db_prep_value\" title=\"django.db.models.Field.get_db_prep_value\"><code class=\"xref py py-meth docutils literal notranslate\">get_db_prep_value()</code></a>.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.pre_save\">\n<span class=\"sig-name descname\">pre_save</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">model_instance</em>, <em class=\"sig-param\">add</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.pre_save\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Method called prior to <a class=\"reference internal\" href=\"#django.db.models.Field.get_db_prep_save\" title=\"django.db.models.Field.get_db_prep_save\"><code class=\"xref py py-meth docutils literal notranslate\">get_db_prep_save()</code></a> to prepare the value\nbefore being saved (e.g. for <a class=\"reference internal\" href=\"#django.db.models.DateField.auto_now\" title=\"django.db.models.DateField.auto_now\"><code class=\"xref py py-attr docutils literal notranslate\">DateField.auto_now</code></a>).</p>\n<p><code class=\"docutils literal notranslate\">model_instance</code> is the instance this field belongs to and <code class=\"docutils literal notranslate\">add</code>\nis whether the instance is being saved to the database for the first\ntime.</p>\n<p>It should return the value of the appropriate attribute from\n<code class=\"docutils literal notranslate\">model_instance</code> for this field. The attribute name is in\n<code class=\"docutils literal notranslate\">self.attname</code> (this is set up by <a class=\"reference internal\" href=\"#django.db.models.Field\" title=\"django.db.models.Field\"><code class=\"xref py py-class docutils literal notranslate\">Field</code></a>).</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#preprocessing-values-before-saving\"><span class=\"std std-ref\">Mengolah nilai sebelum menyimpan</span></a> untuk penggunaan.</p>\n</dd></dl>\n\n<p>Fields often receive their values as a different type, either from\nserialization or from forms.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.to_python\">\n<span class=\"sig-name descname\">to_python</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">value</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.to_python\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Converts the value into the correct Python object. It acts as the\nreverse of <a class=\"reference internal\" href=\"#django.db.models.Field.value_to_string\" title=\"django.db.models.Field.value_to_string\"><code class=\"xref py py-meth docutils literal notranslate\">value_to_string()</code></a>, and is also called in\n<a class=\"reference internal\" href=\"/id/2.0/ref/models/instances/#django.db.models.Model.clean\" title=\"django.db.models.Model.clean\"><code class=\"xref py py-meth docutils literal notranslate\">clean()</code></a>.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#converting-values-to-python-objects\"><span class=\"std std-ref\">Mengubah nilai menjadi obyek Python</span></a> untuk penggunaan.</p>\n</dd></dl>\n\n<p>Besides saving to the database, the field also needs to know how to\nserialize its value:</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.value_to_string\">\n<span class=\"sig-name descname\">value_to_string</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">obj</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.value_to_string\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Merubah <code class=\"docutils literal notranslate\">obj</code> menjadi sebuah string. Digunakan untuk menserialisasikan nilai dari bidang.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#converting-model-field-to-serialization\"><span class=\"std std-ref\">Mengubah data field untuk serialisasi</span></a> untuk penggunaan.</p>\n</dd></dl>\n\n<p>Ketika menggunakan <a class=\"reference internal\" href=\"/id/2.0/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">model forms</code></a>, <code class=\"docutils literal notranslate\">Field</code> butuh mengetahui bidang formulir mana itu harus diwakili:</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.formfield\">\n<span class=\"sig-name descname\">formfield</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">form_class<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">choices_form_class<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\"><span class=\"o\">**</span>kwargs</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.formfield\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Mengembalikan <a class=\"reference internal\" href=\"/id/2.0/ref/forms/fields/#django.forms.Field\" title=\"django.forms.Field\"><code class=\"xref py py-class docutils literal notranslate\">django.forms.Field</code></a> awalan dari bidang ini untuk  <a class=\"reference internal\" href=\"/id/2.0/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a>.</p>\n<p>By default, if both <code class=\"docutils literal notranslate\">form_class</code> and <code class=\"docutils literal notranslate\">choices_form_class</code> are\n<code class=\"docutils literal notranslate\">None</code>, it uses <a class=\"reference internal\" href=\"/id/2.0/ref/forms/fields/#django.forms.CharField\" title=\"django.forms.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a>. If the field has\n<a class=\"reference internal\" href=\"#django.db.models.Field.choices\" title=\"django.db.models.Field.choices\"><code class=\"xref py py-attr docutils literal notranslate\">choices</code></a> and <code class=\"docutils literal notranslate\">choices_form_class</code>\nisn't specified, it uses <a class=\"reference internal\" href=\"/id/2.0/ref/forms/fields/#django.forms.TypedChoiceField\" title=\"django.forms.TypedChoiceField\"><code class=\"xref py py-class docutils literal notranslate\">TypedChoiceField</code></a>.</p>\n<p>Lihat <a class=\"reference internal\" href=\"/id/2.0/howto/custom-model-fields/#specifying-form-field-for-model-field\"><span class=\"std std-ref\">Menentukan bidang formulir untuk sebuah bidang model</span></a>  untuk penggunaan.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.deconstruct\">\n<span class=\"sig-name descname\">deconstruct</span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.deconstruct\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Mengembalikan 4-tuple dengan informasi cukup untuk membuat kembali bidang:</p>\n<ol class=\"arabic simple\">\n<li><p>Nama dari bidang pada model.</p></li>\n<li><p>The import path of the field (e.g. <code class=\"docutils literal notranslate\">&quot;django.db.models.IntegerField&quot;</code>).\nThis should be the most portable version, so less specific may be better.</p></li>\n<li><p>Daftar dari argumen penempatan.</p></li>\n<li><p>A dict of keyword arguments.</p></li>\n</ol>\n<p>This method must be added to fields prior to 1.7 to migrate its data\nusing <a class=\"reference internal\" href=\"/id/2.0/topics/migrations/\"><span class=\"doc\">Perpindahan</span></a>.</p>\n</dd></dl>\n\n</dd></dl>\n\n</section>\n</section>\n<section id=\"field-attribute-reference\">\n<span id=\"model-field-attributes\"></span><h1>Acuan atribut bidang<a class=\"heading-anchor\" href=\"#field-attribute-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Every <code class=\"docutils literal notranslate\">Field</code> instance contains several attributes that allow\nintrospecting its behavior. Use these attributes instead of <code class=\"docutils literal notranslate\">isinstance</code>\nchecks when you need to write code that depends on a field's functionality.\nThese attributes can be used together with the <a class=\"reference internal\" href=\"/id/2.0/ref/models/meta/#model-meta-field-api\"><span class=\"std std-ref\">Model._meta API</span></a> to narrow down a search for specific field types.\nCustom model fields should implement these flags.</p>\n<section id=\"attributes-for-fields\">\n<h2>Atribut untuk bidang<a class=\"heading-anchor\" href=\"#attributes-for-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.auto_created\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">auto_created</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.auto_created\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that indicates if the field was automatically created, such\nas the <code class=\"docutils literal notranslate\">OneToOneField</code> used by model inheritance.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.concrete\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">concrete</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.concrete\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Bendera Boolean mengindikasikan jika bidang mempunyai kolom terkait dengan itu.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.hidden\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">hidden</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.hidden\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that indicates if a field is used to back another non-hidden\nfield's functionality (e.g. the <code class=\"docutils literal notranslate\">content_type</code> and <code class=\"docutils literal notranslate\">object_id</code> fields\nthat make up a <code class=\"docutils literal notranslate\">GenericForeignKey</code>). The <code class=\"docutils literal notranslate\">hidden</code> flag is used to\ndistinguish what constitutes the public subset of fields on the model from\nall the fields on the model.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Catatan</p>\n<p><a class=\"reference internal\" href=\"/id/2.0/ref/models/meta/#django.db.models.options.Options.get_fields\" title=\"django.db.models.options.Options.get_fields\"><code class=\"xref py py-meth docutils literal notranslate\">Options.get_fields()</code></a> tidak menyertakan bidang tersembunyi secara awalan. Lewatkan di <code class=\"docutils literal notranslate\">include_hidden=True</code> untuk mengembalikan bidang-bidang tersembunyi di hasil.</p>\n</aside>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.is_relation\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">is_relation</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.is_relation\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that indicates if a field contains references to one or\nmore other models for its functionality (e.g. <code class=\"docutils literal notranslate\">ForeignKey</code>,\n<code class=\"docutils literal notranslate\">ManyToManyField</code>, <code class=\"docutils literal notranslate\">OneToOneField</code>, etc.).</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.model\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">model</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.model\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the model on which the field is defined. If a field is defined on\na superclass of a model, <code class=\"docutils literal notranslate\">model</code> will refer to the superclass, not the\nclass of the instance.</p>\n</dd></dl>\n\n</section>\n<section id=\"attributes-for-fields-with-relations\">\n<h2>Atribut untuk bidang dengan hubungan<a class=\"heading-anchor\" href=\"#attributes-for-fields-with-relations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>These attributes are used to query for the cardinality and other details of a\nrelation. These attribute are present on all fields; however, they will only\nhave boolean values (rather than <code class=\"docutils literal notranslate\">None</code>) if the field is a relation type\n(<a class=\"reference internal\" href=\"#django.db.models.Field.is_relation\" title=\"django.db.models.Field.is_relation\"><code class=\"xref py py-attr docutils literal notranslate\">Field.is_relation=True</code></a>).</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.many_to_many\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">many_to_many</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.many_to_many\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that is <code class=\"docutils literal notranslate\">True</code> if the field has a many-to-many relation;\n<code class=\"docutils literal notranslate\">False</code> otherwise. The only field included with Django where this is\n<code class=\"docutils literal notranslate\">True</code> is <code class=\"docutils literal notranslate\">ManyToManyField</code>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.many_to_one\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">many_to_one</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.many_to_one\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that is <code class=\"docutils literal notranslate\">True</code> if the field has a many-to-one relation, such\nas a <code class=\"docutils literal notranslate\">ForeignKey</code>; <code class=\"docutils literal notranslate\">False</code> otherwise.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.one_to_many\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">one_to_many</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.one_to_many\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that is <code class=\"docutils literal notranslate\">True</code> if the field has a one-to-many relation, such\nas a <code class=\"docutils literal notranslate\">GenericRelation</code> or the reverse of a <code class=\"docutils literal notranslate\">ForeignKey</code>; <code class=\"docutils literal notranslate\">False</code>\notherwise.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.one_to_one\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">one_to_one</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.one_to_one\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Boolean flag that is <code class=\"docutils literal notranslate\">True</code> if the field has a one-to-one relation, such\nas a <code class=\"docutils literal notranslate\">OneToOneField</code>; <code class=\"docutils literal notranslate\">False</code> otherwise.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.db.models.Field.related_model\">\n<span class=\"sig-prename descclassname\">Field.</span><span class=\"sig-name descname\">related_model</span><a class=\"heading-anchor\" href=\"#django.db.models.Field.related_model\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Points to the model the field relates to. For example, <code class=\"docutils literal notranslate\">Author</code> in\n<code class=\"docutils literal notranslate\">ForeignKey(Author, on_delete=models.CASCADE)</code>. The <code class=\"docutils literal notranslate\">related_model</code> for\na <code class=\"docutils literal notranslate\">GenericForeignKey</code> is always <code class=\"docutils literal notranslate\">None</code>.</p>\n</dd></dl>\n\n</section>\n</section>\n","rootId":"","toc":[{"title":"Model field reference","anchor":"","children":[{"title":"Pilihan bidang","anchor":"field-options","children":[{"title":"null","anchor":"null","children":[]},{"title":"blank","anchor":"blank","children":[]},{"title":"choices","anchor":"choices","children":[]},{"title":"db_column","anchor":"db-column","children":[]},{"title":"db_index","anchor":"db-index","children":[]},{"title":"db_tablespace","anchor":"db-tablespace","children":[]},{"title":"default","anchor":"default","children":[]},{"title":"editable","anchor":"editable","children":[]},{"title":"error_messages","anchor":"error-messages","children":[]},{"title":"help_text","anchor":"help-text","children":[]},{"title":"primary_key","anchor":"primary-key","children":[]},{"title":"unik","anchor":"unique","children":[]},{"title":"unique_for_date","anchor":"unique-for-date","children":[]},{"title":"unique_for_month","anchor":"unique-for-month","children":[]},{"title":"unique_for_year","anchor":"unique-for-year","children":[]},{"title":"verbose_name","anchor":"verbose-name","children":[]},{"title":"validators","anchor":"validators","children":[{"title":"Registering and fetching lookups","anchor":"registering-and-fetching-lookups","children":[]}]}]},{"title":"Jenis bidang","anchor":"field-types","children":[{"title":"AutoField","anchor":"autofield","children":[]},{"title":"BigAutoField","anchor":"bigautofield","children":[]},{"title":"BigIntegerField","anchor":"bigintegerfield","children":[]},{"title":"BinaryField","anchor":"binaryfield","children":[]},{"title":"BooleanField","anchor":"booleanfield","children":[]},{"title":"CharField","anchor":"charfield","children":[]},{"title":"DateField","anchor":"datefield","children":[]},{"title":"DateTimeField","anchor":"datetimefield","children":[]},{"title":"DecimalField","anchor":"decimalfield","children":[]},{"title":"DurationField","anchor":"durationfield","children":[]},{"title":"EmailField","anchor":"emailfield","children":[]},{"title":"FileField","anchor":"filefield","children":[{"title":"FileField dan FieldFile","anchor":"filefield-and-fieldfile","children":[]}]},{"title":"FilePathField","anchor":"filepathfield","children":[]},{"title":"FloatField","anchor":"floatfield","children":[]},{"title":"ImageField","anchor":"imagefield","children":[]},{"title":"IntegerField","anchor":"integerfield","children":[]},{"title":"GenericIPAddressField","anchor":"genericipaddressfield","children":[]},{"title":"NullBooleanField","anchor":"nullbooleanfield","children":[]},{"title":"PositiveIntegerField","anchor":"positiveintegerfield","children":[]},{"title":"PositiveSmallIntegerField","anchor":"positivesmallintegerfield","children":[]},{"title":"SlugField","anchor":"slugfield","children":[]},{"title":"SmallIntegerField","anchor":"smallintegerfield","children":[]},{"title":"TextField","anchor":"textfield","children":[]},{"title":"TimeField","anchor":"timefield","children":[]},{"title":"URLField","anchor":"urlfield","children":[]},{"title":"UUIDField","anchor":"uuidfield","children":[]}]},{"title":"Bidang hubungan","anchor":"module-django.db.models.fields.related","children":[{"title":"ForeignKey","anchor":"foreignkey","children":[{"title":"Perwakilan Basisdata","anchor":"database-representation","children":[]},{"title":"Penjelasan","anchor":"arguments","children":[]}]},{"title":"ManyToManyField","anchor":"manytomanyfield","children":[{"title":"Perwakilan Basisdata","anchor":"id1","children":[]},{"title":"Penjelasan","anchor":"manytomany-arguments","children":[]}]},{"title":"OneToOneField","anchor":"onetoonefield","children":[]}]},{"title":"Field API reference","anchor":"field-api-reference","children":[]}]},{"title":"Acuan atribut bidang","anchor":"field-attribute-reference","children":[{"title":"Atribut untuk bidang","anchor":"attributes-for-fields","children":[]},{"title":"Atribut untuk bidang dengan hubungan","anchor":"attributes-for-fields-with-relations","children":[]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Acuan API","url":"/id/2.0/ref/"},{"docname":"ref/models/index","title":"Model","url":"/id/2.0/ref/models/"}],"prev":{"docname":"ref/models/index","title":"Model","url":"/id/2.0/ref/models/"},"next":{"docname":"ref/models/indexes","title":"Model index reference","url":"/id/2.0/ref/models/indexes/"},"formats":{"html":"/id/2.0/ref/models/fields/","markdown":"/id/2.0/ref/models/fields.md","json":"/id/2.0/ref/models/fields.json"},"source":"https://github.com/django/django/blob/stable/2.0.x/docs/ref/models/fields.txt","official":"https://docs.djangoproject.com/id/2.0/ref/models/fields/","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"]}