>

나는 ValueError 를 계속 받고있다  Heroku에서 마이그레이션을 실행할 때. 내 장고 응용 프로그램은 로컬로 문제없이 작동합니다. 내가 볼 수있는 것에서 나는이 모델에 문제가 있다고 생각하지만 그것이 무엇인지 알 수는 없습니다. 특히 makemigrations 를 실행하기 때문에  로컬로 마이그레이션하면 제대로 작동합니다.

내 오류 : (주 : heroku에서만 실행할 때 : heroku run python manage.py migrate )

Running python manage.py migrate on ⬢ nameless-sands-... up, run.1867 (Free)
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, narocilnice, sessions
Running migrations:
  Applying narocilnice.0012_auto_20170808_1312...Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 215, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 515, in alter_field
    old_db_params, new_db_params, strict)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py", line 112, in _alter_field
    new_db_params, strict,
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 613, in _alter_field
    new_default = self.effective_default(new_field)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 229, in effective_default
    default = field.get_db_prep_save(default, self.connection)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 770, in get_db_prep_save
    prepared=False)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 762, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1853, in get_prep_value
    return int(value)
ValueError: invalid literal for int() with base 10: '-'

  • 답변 # 1

    0012_auto_20170808_1312.py 파일을 변경했습니다. 정수 필드에 기본값이 "-"인 경우 줄이있었습니다. 삭제했습니다. 그러나 나는 왜 이것이 로컬로 이것이 문제가되지 않았는지 아직도 모른다.

관련 자료

  • 이전 java - AtomicReference를 휘발성 멤버로 교체하는 것이 언제 적절한가요?
  • 다음 javascript - windowlocation이 올바르게 업데이트되지 않습니다