日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

django.db.utils.OperationalError: no such column: catalogue_product.is_public

發(fā)布時間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 django.db.utils.OperationalError: no such column: catalogue_product.is_public 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

報錯來自django-oscar從低版本向高版本遷移的時候發(fā)生的.

完整報錯如下:

Traceback (most recent call last):
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
??? return self.cursor.execute(sql, params)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 383, in execute
??? return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such column: catalogue_product.is_public

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
??? response = get_response(request)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
??? response = self.process_exception_by_middleware(e, request)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
??? response = wrapped_callback(request, *callback_args, **callback_kwargs)
? File "/usr/lib/python3.7/contextlib.py", line 74, in inner
??? return func(*args, **kwds)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
??? return self.dispatch(request, *args, **kwargs)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
??? return handler(request, *args, **kwargs)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/oscar/apps/catalogue/views.py", line 136, in get
??? return super().get(request, *args, **kwargs)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/views/generic/base.py", line 158, in get
??? context = self.get_context_data(**kwargs)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/oscar/apps/catalogue/views.py", line 145, in get_context_data
??? self.context_object_name)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/oscar/apps/catalogue/search_handlers.py", line 106, in get_search_context_data
??? context = self.get_context_data(object_list=self.object_list)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/views/generic/list.py", line 119, in get_context_data
??? paginator, page, queryset, is_paginated = self.paginate_queryset(queryset, page_size)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/views/generic/list.py", line 69, in paginate_queryset
??? page = paginator.page(page_number)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/paginator.py", line 70, in page
??? number = self.validate_number(number)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/paginator.py", line 48, in validate_number
??? if number > self.num_pages:
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
??? res = instance.__dict__[self.name] = self.func(instance)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/paginator.py", line 97, in num_pages
??? if self.count == 0 and not self.allow_empty_first_page:
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
??? res = instance.__dict__[self.name] = self.func(instance)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/paginator.py", line 91, in count
??? return c()
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/models/query.py", line 392, in count
??? return self.query.get_count(using=self.db)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/models/sql/query.py", line 504, in get_count
??? number = obj.get_aggregation(using, ['__count'])['__count']
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/models/sql/query.py", line 489, in get_aggregation
??? result = compiler.execute_sql(SINGLE)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1133, in execute_sql
??? cursor.execute(sql, params)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute
??? return super().execute(sql, params)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
??? return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
??? return executor(sql, params, many, context)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
??? return self.cursor.execute(sql, params)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
??? raise dj_exc_value.with_traceback(traceback) from exc_value
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
??? return self.cursor.execute(sql, params)
? File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 383, in execute
??? return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such column: catalogue_product.is_public
[07/Mar/2020 17:17:13] "GET /catalogue/ HTTP/1.1" 500 229440

解決方案:

稍微復(fù)雜,你需要首先定義一個

is_public的字段

然后賦值

然后才能選擇NN(not null)

你并不能一開始在新建字段的時候,

就選擇NN,DB Browser fro SQLite會報錯

?

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的django.db.utils.OperationalError: no such column: catalogue_product.is_public的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。