메타 장고 인덱스가 없습니다.
-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입니다. 이는 명시적 값이 없는 필드에 대한 기본값을 지정하려는 경우 또는 데이터베이스에서 자동으로 채워지는 필드에 대한 기본값을 지정하려는 경우에 유용할 수 있습니다.
또 다른 메타 옵션은 객체를 데이터베이스에 저장할 때 사용해야 하는 직렬 변환기를 지정하는 직렬 변환기입니다. 이는 Django에서 자동으로 제공하는 것과 다른 직렬 변환기를 사용하려는 경우에 유용할 수 있습니다.