Django 장고8 장고에서 model생성 시 데이터베이스 인덱스를 추가하는 방법 db_index=True만 붙이면 된다. 그리고 마이그레이션!from django.db import modelsfrom settingapp.models import Camera, DetectModelclass Item(models.Model): camera = models.ForeignKey(Camera, to_field='id', on_delete=models.DO_NOTHING, null=True) start_timestamp = models.BigIntegerField(default=None, null=True, db_index=True) class Meta: db_table = 'item' 2025. 2. 19. 장고에서 아무리 로그인해도 user로그인이 안먹힌다 settings.py에 이거 선언을 안해서 그럼 -->AUTH_USER_MODEL = 'settingapp.User' 2025. 1. 20. 413 Request Entity Too Large 에러 고치는 방법: # settings.pyDATA_UPLOAD_MAX_MEMORY_SIZE = 10485760 # 10MB (원하는 크기로 설정) nginx.confhttp { client_max_body_size 1073741824; 2024. 11. 12. 원투매니에서 발생하는 플러스원 이슈 gpt 대답: 원투매니(One-to-Many) 관계에서 발생하는 "플러스원" 이슈는 데이터베이스 쿼리에서 N+1 문제(N+1 Query Problem)로 불리며, ORM(Object-Relational Mapping)을 사용할 때 자주 발생하는 성능 관련 문제입니다.N+1 문제란?N+1 문제는 데이터베이스에서 "1개의 주요 쿼리"와 관련된 "N개의 추가 쿼리"가 불필요하게 발생하는 상황을 말합니다. 주로 1대 다 관계에서 발생하며, 데이터를 불러올 때 각 항목에 대해 추가적인 쿼리를 실행하는 방식 때문에 성능 저하가 발생합니다.N+1 문제 예시Django ORM에서 Author와 Book이 One-to-Many 관계라고 가정해보겠습니다. 하나의 Author는 여러 권의 Book을 가질 수 있습니다.py.. 2024. 10. 24. 장고 no reload로 키기 --noreload로 실행하지 않으면 두번 실행된다..!python manage.py runserver --noreload 2024. 9. 11. 장고 date가 'null' 로 들어가서 나는 에러 해결 장고 date가 'null' 로 들어가서 나는 에러 해결에러메세지: [2024-07-02 17:48:25,232] INFO [machinesiteapp.views:273] [user:super(super) app:F] site edit false : {'site_build_date': [ErrorDetail(string='Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].', code='invalid')], 'audit_start_date': [ErrorDetail(string='Datetime has wrong format. Use one of these fo.. 2024. 7. 2. foreign key를 null=true로 했는데 Column 'form_id' cannot be null이 나온다(mac) 뽀린키 속성을 없앤다 Find the name of the foreign key constraint (you can see it in the error message or by looking up the table structure), and then drop it:ALTER TABLE machine_report_attachment DROP FOREIGN KEY machine_report_attac_form_id_b4c038bd_fk_machine_r;form_id속성을 다시 부여한다 Now, modify the column to be nullable as initially intended:ALTER TABLE machine_report_attachment MODIFY form_id BIGINT NULL.. 2024. 6. 26. mysql접속할 수 없는상태에서 비밀번호 변경 mysql 멈추기mysql.server stop 안전모드에서 시작sudo mysqld_safe --skip-grant-tables --skip-networking & mysql접속mysql -u root 비밀번호 재설정FLUSH PRIVILEGES;USE mysql;alter user 'root'@'localhost' identified with caching_sha2_password by '변경할 비밀번호';FLUSH PRIVILEGES; 재시작mysql.server restart; 2024. 6. 26. 이전 1 다음