メタ django インデックスはありません。
-admin I am trying to add an index to my Django model. I have tried using the <code>db_index=True</code> and <code>index_together</code> fields, but they don't seem to work. I have also tried using the <code>Meta</code> class, but it doesn't seem to work either. <blockquote> <p><strong><em><a href="https://docs.djangoproject.com/en/dev/ref/models/options/#indexes" rel="nofollow noreferrer">https://docs.djangoproject.com/en/dev/ref/models/options/#indexes</a></em></strong></p> <p><strong><em><a href="https://docs.djangoproject.com/en/dev/ref/models/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/dev//ref//models//options/#db-indexes</a></em></strong></p> <p><strong><em><a href="https://stackoverflow.com/?q=add+an+index+in+Django">add an index in Django</a></em></strong></p> <p><strong><em>(and many more)</em></strong>. </p> </blockquote>
上記のコードは、Django モデルにインデックスを追加しようとしています。 の db_index=True
& index_together
フィールドが使用されていますが、機能していないようです。 の Meta
クラスも使用されていますが、どちらも機能していないようです。
モデルインデックス参照
モデル インデックス参照は、モデル インスタンスの一意の識別子を格納するモデル内のフィールドです。 このフィールドは、Django がデータベースにアクセスするときにモデル インスタンスを一意に識別するために使用されます。
モデル メタ オプション
モデルの動作を制御するために Django で使用できるいくつかのメタ オプションがあります。
最も一般的なメタ オプションは、モデルの default_field です。これは、新しいオブジェクトが作成されたときに、データベース内のどのフィールドをモデルのデフォルト値として使用するかを指定します。 これは、明示的な値を持たないフィールドのデフォルト値を指定する場合、またはデータベースによって自動的に入力されるフィールドのデフォルト値を指定する場合に役立ちます。
もう XNUMX つのメタ オプションは serializer です。これは、オブジェクトをデータベースに保存するときに使用するシリアライザーを指定します。 これは、Django によって自動的に提供されるものとは異なるシリアライザーを使用する場合に役立ちます。