Я создал веб-сайт с django и mysql, и когда я попытался развернуть его на heroku, развертывание прошло успешно, но если я пытаюсь получить доступ к своему веб-сайту, я получаю эту ошибку:
2020-03-04T02:41:33.999463+00:00 app[web.1]: Internal Server Error: /
2020-03-04T02:41:33.999471+00:00 app[web.1]: Traceback (most recent call last):
2020-03-04T02:41:33.999472+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
2020-03-04T02:41:33.999472+00:00 app[web.1]: return self.cursor.execute(sql, params)
2020-03-04T02:41:33.999473+00:00 app[web.1]: psycopg2.errors.UndefinedFunction: operator does not exist: date = boolean
2020-03-04T02:41:33.999473+00:00 app[web.1]: LINE 1: ...ng_createdeal" WHERE "booking_createdeal"."available" = true
2020-03-04T02:41:33.999474+00:00 app[web.1]: ^
2020-03-04T02:41:33.999474+00:00 app[web.1]: HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
2020-03-04T02:41:33.999475+00:00 app[web.1]:
2020-03-04T02:41:33.999475+00:00 app[web.1]:
2020-03-04T02:41:33.999476+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2020-03-04T02:41:33.999476+00:00 app[web.1]:
2020-03-04T02:41:33.999477+00:00 app[web.1]: Traceback (most recent call last):
2020-03-04T02:41:33.999477+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-03-04T02:41:33.999478+00:00 app[web.1]: response = get_response(request)
2020-03-04T02:41:33.999478+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
2020-03-04T02:41:33.999479+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request)
2020-03-04T02:41:33.999479+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
2020-03-04T02:41:33.999480+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2020-03-04T02:41:33.999480+00:00 app[web.1]: File "/app/booking/views.py", line 20, in index
2020-03-04T02:41:33.999481+00:00 app[web.1]: return render(request, 'base.html', {'all_deals': all_deals, 'description': description})
2020-03-04T02:41:33.999481+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/shortcuts.py", line 19, in render
2020-03-04T02:41:33.999482+00:00 app[web.1]: content = loader.render_to_string(template_name, context, request, using=using)
2020-03-04T02:41:33.999482+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string
2020-03-04T02:41:33.999483+00:00 app[web.1]: return template.render(context, request)
2020-03-04T02:41:33.999483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
2020-03-04T02:41:33.999484+00:00 app[web.1]: return self.template.render(context)
2020-03-04T02:41:33.999484+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 171, in render
2020-03-04T02:41:33.999484+00:00 app[web.1]: return self._render(context)
2020-03-04T02:41:33.999485+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
2020-03-04T02:41:33.999485+00:00 app[web.1]: return self.nodelist.render(context)
2020-03-04T02:41:33.999485+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 936, in render
2020-03-04T02:41:33.999486+00:00 app[web.1]: bit = node.render_annotated(context)
2020-03-04T02:41:33.999486+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 903, in render_annotated
2020-03-04T02:41:33.999487+00:00 app[web.1]: return self.render(context)
2020-03-04T02:41:33.999487+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py", line 53, in render
2020-03-04T02:41:33.999488+00:00 app[web.1]: result = self.nodelist.render(context)
2020-03-04T02:41:33.999488+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 936, in render
2020-03-04T02:41:33.999489+00:00 app[web.1]: bit = node.render_annotated(context)
2020-03-04T02:41:33.999489+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 903, in render_annotated
2020-03-04T02:41:33.999489+00:00 app[web.1]: return self.render(context)
2020-03-04T02:41:33.999490+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/defaulttags.py", line 166, in render
2020-03-04T02:41:33.999490+00:00 app[web.1]: len_values = len(values)
2020-03-04T02:41:33.999491+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 258, in __len__
2020-03-04T02:41:33.999491+00:00 app[web.1]: self._fetch_all()
2020-03-04T02:41:33.999491+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 1261, in _fetch_all
2020-03-04T02:41:33.999492+00:00 app[web.1]: self._result_cache = list(self._iterable_class(self))
2020-03-04T02:41:33.999492+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 57, in __iter__
2020-03-04T02:41:33.999492+00:00 app[web.1]: results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
2020-03-04T02:41:33.999493+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1144, in execute_sql
2020-03-04T02:41:33.999493+00:00 app[web.1]: cursor.execute(sql, params)
2020-03-04T02:41:33.999493+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
2020-03-04T02:41:33.999494+00:00 app[web.1]: return super().execute(sql, params)
2020-03-04T02:41:33.999494+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
2020-03-04T02:41:33.999495+00:00 app[web.1]: return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
2020-03-04T02:41:33.999495+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
2020-03-04T02:41:33.999495+00:00 app[web.1]: return executor(sql, params, many, context)
2020-03-04T02:41:33.999502+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
2020-03-04T02:41:33.999503+00:00 app[web.1]: return self.cursor.execute(sql, params)
2020-03-04T02:41:33.999503+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
2020-03-04T02:41:33.999503+00:00 app[web.1]: raise dj_exc_value.with_traceback(traceback) from exc_value
2020-03-04T02:41:33.999504+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
2020-03-04T02:41:33.999504+00:00 app[web.1]: return self.cursor.execute(sql, params)
2020-03-04T02:41:33.999505+00:00 app[web.1]: django.db.utils.ProgrammingError: operator does not exist: date = boolean
2020-03-04T02:41:33.999505+00:00 app[web.1]: LINE 1: ...ng_createdeal" WHERE "booking_createdeal"."available" = true
2020-03-04T02:41:33.999505+00:00 app[web.1]: ^
2020-03-04T02:41:33.999506+00:00 app[web.1]: HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
Я думаю, что это проблема при переходе от mysql к postgresql.
В моем приложении booking
у меня есть модель CreateDeal
, и изначально у меня было поле available
, установленное на DateField
и после того, как я решил сделать это BooleanField
, вот мои файлы миграции:
0001_initial.py :
# ...
operations = [
migrations.CreateModel(
name='CreateDeal',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
# ...
('available', models.DateField(default=datetime.date.today)),
# ...
],
),
]
0004_auto_20200224_2007.py :
# ...
operations = [
# ...
migrations.AlterField(
model_name='createdeal',
name='available',
field=models.BooleanField(default=True),
),
]
Я пытался удалить из миграция 4 модификацию поля available
и установить в миграцию 1 на то, что у меня в миграция 4 но у меня все та же ошибка, как я могу это исправить, пожалуйста