Я запускаю приложение Django в течение нескольких лет, и оно неожиданно начало выдавать ошибки при обновлении базы данных Postgres, используемой для управления живым сайтом. Когда я тестирую с использованием базы данных SQLite, никаких проблем не возникает. Всякий раз, когда я пытаюсь внести какие-либо изменения в объекты базы данных, я получаю ошибку invalid literal for int() with base 10: ''
.
Это трассировка, которую я получаю:
Traceback:
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\core\handlers\exception.py" in inner
41. response = get_response(request)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File ".\Indicators\views.py" in edit_indicator
227. indicator_to_be_edited.save()
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\base.py" in save
806. force_update=force_update, update_fields=update_fields)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\base.py" in save_base
836. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\base.py" in _save_table
903. forced_update)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\base.py" in _do_update
953. return filtered._update(values) > 0
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\query.py" in _update
664. return query.get_compiler(self.db).execute_sql(CURSOR)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
1191. cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
863. sql, params = self.as_sql()
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\sql\compiler.py" in as_sql
1157. val = field.get_db_prep_save(val, connection=self.connection)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\fields\__init__.py" in get_db_prep_save
770. prepared=False)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\fields\__init__.py" in get_db_prep_value
762. value = self.get_prep_value(value)
File "C:\ProgramData\Anaconda34\envs\py34\lib\site-packages\django\db\models\fields\__init__.py" in get_prep_value
1853. return int(value)
Exception Type: ValueError at /edit-indicator/
Exception Value: invalid literal for int() with base 10: ''
Это модель, которую я пытаюсь обновить:
class Indicator(models.Model):
time_periods = get_time_periods()
months = get_months()
calculations = get_calculations()
sex_ids = get_all_sexes()
age_ids = sort_all_ages()
operands = (
('+', '+'),
('-', '-'),
('*', '*'),
('/', '/')
)
salt_options = get_salt_options_as_tuple()
qof_data_choices = get_qof_choices_as_tuple()
id = models.IntegerField(unique=True, primary_key=True)
source_data_family = models.ForeignKey(IndicatorFamily, on_delete=models.CASCADE, blank=True)
qof_source_data = models.CharField(max_length=100, choices=qof_data_choices, blank=True)
source_sheet = models.CharField(max_length=200, blank=True)
year_range = models.CharField(max_length=2, blank=True)
time_period = models.CharField(max_length=30, choices=time_periods, blank=True)
ageId = models.IntegerField(choices=age_ids, blank=True)
sexId = models.IntegerField(choices=sex_ids)
calculation = models.CharField(max_length=30, choices=calculations, blank=True)
rate = models.IntegerField(blank=True, null=True)
value_declared_independently = models.BooleanField(default=False)
value_column_name = models.CharField(max_length=200, blank=True)
numerator_starts_with_financial_year = models.BooleanField(default=False)
numerator = models.CharField(max_length=200, blank=True)
salt_numerator = models.CharField(max_length=200, blank=True, choices=salt_options)
salt_numerator_operand = models.CharField(max_length=2, choices=operands, blank=True)
salt_numerator_2 = models.CharField(max_length=200, blank=True, choices=salt_options)
numerator_minus_not_caseness = models.BooleanField(default=False)
iapt_q_m_variable_type = models.CharField(max_length=200, blank=True)
iapt_q_m_variable_a = models.CharField(max_length=200, blank=True)
iapt_q_m_variable_b = models.CharField(max_length=200, blank=True)
iapt_q_m_variable_type_denominator = models.CharField(max_length=200, blank=True)
iapt_q_m_variable_a_denominator = models.CharField(max_length=200, blank=True)
iapt_q_m_variable_b_denominator = models.CharField(max_length=200, blank=True)
denominator_starts_with_financial_year = models.BooleanField(default=False)
denominator = models.CharField(max_length=200, blank=True)
denominator_minus_not_caseness = models.BooleanField(default=False)
denominator_source_sheet = models.CharField(max_length=200, blank=True)
salt_denominator = models.CharField(max_length=200, blank=True, choices=salt_options)
salt_denominator_operand = models.CharField(max_length=2, choices=operands, blank=True)
salt_denominator_2 = models.CharField(max_length=200, blank=True, choices=salt_options)
add_denominator_column = models.CharField(max_length=200, blank=True)
additional_denominator_column_starts_with_financial_year = models.BooleanField(default=False)
adjust_denominator_for_person_years = models.BooleanField(default=False)
ccg_over_18_population_as_denominator = models.BooleanField(default=False)
ccg_total_population_as_denominator = models.BooleanField(default=False)
is_count = models.BooleanField(default=False)
is_percentage = models.BooleanField(default=False)
ccg_to_stp = models.BooleanField(default=False)
gp_to_upper_tier_la = models.BooleanField(default=False)
ccg_lookup_required = models.BooleanField(default=False)
drop_depression = models.BooleanField(default=False)
count_non_nulls = models.BooleanField(default=False)
non_null_columns = models.CharField(max_length=300, blank=True)
drop_eng_row = models.BooleanField(default=False)
months_to_quarter = models.BooleanField(default=False)
snapshot = models.BooleanField(default=False)
asterisk_as_two = models.BooleanField(default=False)
creator = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
denominator_2_equals_denominator = models.BooleanField(default=False)
do_not_suppress_small_numbers = models.BooleanField(default=False)
numerator_is_num_minus_denom = models.BooleanField(default=False)
stp_is_average_not_sum = models.BooleanField(default=False)
mental_health_trust_geographies = models.BooleanField(default=False)
filter_by = models.CharField(max_length=200, blank=True)
quarters_to_year = models.BooleanField(default=False)
Может кто-нибудь пролить свет на то, почемуэто будет происходить?