neh*_*iah 2 django django-models
这是场景:
psql提示。python manage.py shell或shell_plus是否可以使用Django内部函数删除该数据库的列?我知道理论上是可能的。
欢迎任何见解。
正如Cezar所指出的那样,这不应该是一个挑战,就像python manage.py dbshell应该那样调用提示psql。
如果没有其他效果,您仍然可以解决,因为Django允许从shell执行任意(原始)SQL。下面的代码片段应该做到这一点:
from django.db import connection
cursor = connection.cursor()
cursor.execute("alter table table_name DROP column column_name")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
713 次 |
| 最近记录: |