- regexp
- migrations
- Django
- distinct
- 완전검색
- SQL
- N:1
- outer join
- 그리디
- stack
- Tree
- count
- Article & User
- drf
- Vue
- Queue
- 트리
- 뷰
- M:N
- 이진트리
- update
- 쟝고
- 백트래킹
- delete
- DB
- create
- 통계학
- 큐
- 스택
- ORM
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
목록SW/DB (27)
데이터 분석 기술 블로그

1. shell_plus 실행 및 게시글 작성 python manage.py shell_plus # 게시글 생성 Article.objects.create(title='title', content='content') 2. 댓글 생성 # Comment 클래스의 인스턴스 comment 생성 comment = Comment() # 인스턴스 변수 저장 comment.content = 'first comment' # DB에 댓글 저장 comment.save() # 에러 발생 django.db.utils.IntegrityError: NOT NULL constraint failed: articles_comment.article_id # articles_comment 테이블의 ForeignKeyField, article..

1. 댓글 모델 정의 ForeignKey() 클래스의 인스턴스 이름은 참조하는 모델 클래스 이름의 단수형으로 작성하는 것을 권장합니다. ForiegnKey 클래스를 작성하는 위치와 관계없이 외래 키는 테이블 필드 마지막에 생성됩니다. # articles/models.py class Comment(models.Model): article = models.ForeignKey(Article, on_delete=models.CASCADE) content = models.CharField(max_length=200) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(atuo_now=True) 2. Forign..