본문 바로가기

Develop/Python

[Django] Use Django ORM without migrate

Django ORM is wonderful framwork!!

When you want to use it without migrate, can setting simply.

Just set managed option to True on Meta class.


class TestModel(models.Model):
name = models.CharField()
...
class Meta:
managed = False


Defaults to True, meaning Django will create the appropriate database tables in migrate or as part of migrations and remove them as part of a flush management command.

That is, Django manages the database tables’ lifecycles.


If False, no database table creation or deletion operations will be performed for this model.

This is useful if the model represents an existing table or a database view that has been created by some other means.

'Develop > Python' 카테고리의 다른 글

Make Django Server on Centos7  (0) 2018.02.20
[Python] pip install error  (0) 2018.02.19
[Python] 파일 읽고 쓰기  (0) 2018.01.23