본디 프로그래밍은 불편한것을 누군가 항상 해결해 놓았다!
python manage.py inspectdb
이 명령어를 쓴다면, 연결해 놓은 DB를 들여다보며 자동으로 코딩으로 되돌려준다.
python
python manage.py inspectdb
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
class AuthGroup(models.Model):
name = models.CharField(unique=True, max_length=150)
class Meta:
managed = False
db_table = 'auth_group'
.
.
.
manged 속성은 False일때 더이상 이 테이블은 DB에 반영하지 않겠다라는 뜻.
참고: https://dev.to/idrisrampurawala/creating-django-models-of-an-existing-db-288m