장고 모델은장고 마이그레이션 문제
from django.db import models
class Vender(models.Model):
id =models.IntegerField(primary_key=True)
name = models.CharField(max_length=30)
class Meta:
db_table="vendor"
class car(models.Model):
id =models.IntegerField(primary_key=True)
Vender=models.ForeignKey(Vender)
carmodel =models.CharField(max_length=30)
class Meta:
db_table="car"
처음 makemigration
및 migrate
는 괜찮 았는데 다음과 같습니다. 그런 다음 일부 모델 필드와 옵션을 변경했습니다. 그 다음 오류가 발생합니다. 나는 장고를 처음 사용한다. 이러한 종류의 문제는 실제 트랜잭션 데이터를 사용하지 않고 해결할 수있는 생산 방식에서 발생합니다.
F:\Workspace\virtspace\demosrc>python manage.py migrate
Operations to perform:
Apply all migrations: admin, contenttypes, base, auth, sessions
Running migrations:
Applying base.0003_auto_20150110_2004...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Python27\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "D:\Python27\lib\site-packages\django\core\management\base.py", line 338, in execute
output = self.handle(*args, **options)
File "D:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 97, in apply_migration
migration.apply(project_state, schema_editor)
File "D:\Python27\lib\site-packages\django\db\migrations\migration.py", line 107, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
File "D:\Python27\lib\site-packages\django\db\migrations\operations\fields.py", line 84, in database_forwards
schema_editor.remove_field(from_model, from_model._meta.get_field_by_name(self.name)[0])
File "D:\Python27\lib\site-packages\django\db\backends\schema.py", line 439, in remove_field
self.execute(sql)
File "D:\Python27\lib\site-packages\django\db\backends\schema.py", line 99, in execute
cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\oracle\base.py", line 916, in execute
return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00904: "ID": invalid identifier
어떤 오류가 있습니까? 질문에 오류가 없습니다. –
처음에는 makemigration 및 마이그레이션이 정상적으로 작동했습니다. 그런 다음 일부 모델 필드와 옵션을 변경했습니다. 그 다음 오류가 발생합니다. 나는 django를 처음 접하고 장고를 공부하고 있습니다. 생산 측면이 오류를 어떻게 처리 할 수 있습니까? – prakash
모든 세부 사항을 질문에 넣어주십시오. 주석은 자세한 논의가 아닙니다. 주목할 점은 질문에 오류 메시지가 없다는 것입니다. 전체 오류 메시지 (전체 스택 추적)로 업데이트하십시오. –