- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试运行不是由我编写的应用程序。当我写python manage.py makemigrations
我得到了:
Traceback (most recent call last):
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: django_content_type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 341, in execute
django.setup()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 115, in populate
app_config.ready()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\apps.py", line 23, in ready
self.module.autodiscover()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\direwolf\Documents\web\python\alexbog80-motivity-3e5c21f03b3e\app\motivity\admin.py", line 23, in <module>
admin.site.register(Offer, OfferAdmin)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\sites.py", line 110, in register
system_check_errors.extend(admin_obj.check())
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\options.py", line 117, in check
return self.checks_class().check(self, **kwargs)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 520, in check
errors.extend(self._check_list_display(admin_obj))
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 596, in _check_list_display
for index, item in enumerate(obj.list_display)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 596, in <listcomp>
for index, item in enumerate(obj.list_display)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 604, in _check_list_display_item
elif hasattr(model, item):
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\fields.py", line 55, in __get__
return edit_string_for_tags(Tag.objects.usage_for_model(owner))
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\models.py", line 157, in usage_for_model
usage = self.usage_for_queryset(queryset, counts, min_count)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\models.py", line 183, in usage_for_queryset
extra_joins, extra_criteria, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\models.py", line 113, in _get_usage
'content_type_id': ContentType.objects.get_for_model(model).pk,
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\contenttypes\models.py", line 52, in get_for_model
ct = self.get(app_label=opts.app_label, model=opts.model_name)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 379, in get
num = len(clone)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 238, in __len__
self._fetch_all()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 54, in __iter__
results = compiler.execute_sql()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\sql\compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: django_content_type
我该怎么办?
更新 1:python manage.py migrate
回溯:
Traceback (most recent call last):
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: django_content_type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 341, in execute
django.setup()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 115, in populate
app_config.ready()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\apps.py", line 23, in ready
self.module.autodiscover()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\direwolf\Documents\web\python\alexbog80-motivity-3e5c21f03b3e\app\motivity\admin.py", line 23, in <module>
admin.site.register(Offer, OfferAdmin)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\sites.py", line 110, in register
system_check_errors.extend(admin_obj.check())
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\options.py", line 117, in check
return self.checks_class().check(self, **kwargs)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 520, in check
errors.extend(self._check_list_display(admin_obj))
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 596, in _check_list_display
for index, item in enumerate(obj.list_display)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 596, in <listcomp>
for index, item in enumerate(obj.list_display)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\admin\checks.py", line 604, in _check_list_display_item
elif hasattr(model, item):
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\fields.py", line 55, in __get__
return edit_string_for_tags(Tag.objects.usage_for_model(owner))
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\models.py", line 157, in usage_for_model
usage = self.usage_for_queryset(queryset, counts, min_count)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\models.py", line 183, in usage_for_queryset
extra_joins, extra_criteria, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tagging\models.py", line 113, in _get_usage
'content_type_id': ContentType.objects.get_for_model(model).pk,
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\contenttypes\models.py", line 52, in get_for_model
ct = self.get(app_label=opts.app_label, model=opts.model_name)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 379, in get
num = len(clone)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 238, in __len__
self._fetch_all()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 54, in __iter__
results = compiler.execute_sql()
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\sql\compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\direwolf\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils
.OperationalError: 没有这样的表:django_content_type
更新 2:在 models.py
class Offer(TimeStampMixin, SEOFieldsMixin):
title = models.CharField(u'Название предложения', max_length=255, blank=False)
discription = models.TextField(u'Красивое описание оффера', null=False, blank=False)
cover = models.ImageField(u'Обложка', blank=False, null=False)
tags = TagAutocompleteField(blank=False, verbose_name='Теги')
active = models.BooleanField(u'Активный?', default=True)
publish = models.BooleanField(u'Показывать на сайте?', default=True)
def preview_image(self):
# try:
thumbnail = get_thumbnail(self.cover, 'x50', crop='center')
# except TypeError:
# return u'Нет картинки'
# except:
# return u'Нет картинки' # if original img not exist
return '<a href="%s/"><img src="%s"/></a>' % (self.id, thumbnail.url)
preview_image.short_description = u'Обложка'
preview_image.allow_tags = True
class Meta:
verbose_name = u'Предложение'
verbose_name_plural = u'Предложения'
ordering = ('-modified_value',)
get_latest_by = 'created_value'
def __unicode__(self):
return u'%s' % self.title
我没有找到管理类只有这个:
from django.contrib import admin
from app.motivity.models import TaskOffer, Offer, UserOffers
class TaskOfferAdmin(admin.TabularInline):
model = TaskOffer
exclude = ['meta_title', 'meta_description', 'meta_keywords']
class OfferAdmin(admin.ModelAdmin):
list_display = ['preview_image','title','tags', 'publish']
list_display_links = ['title']
list_filter = ['tags']
inlines = [TaskOfferAdmin, ]
fields = ['title', 'discription', 'cover', 'tags']
class UserOfferAdmin(admin.ModelAdmin):
pass
admin.site.register(UserOffers, UserOfferAdmin)
admin.site.register(Offer, OfferAdmin)
最佳答案
我在 Mac OS 10.15.2 上使用 Python 3.6.5 和 Django==2.1.7 时遇到了同样的问题。我通过手动创建表 django_content_type
来修复它列:id, app_label, model
正在运行python manage.py migrate
并且出现错误,应该有一个*.sqlite3
在 DATABASE
上指定的路径上创建的文件您的 settings.py
中的 key 文件。
示例:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'base_site.sqlite3'),
}
}
我的 Sqlite 数据库文件名是 base_site.sqlite3
并创建于 BASE_DIR
项目的。
要遵循的步骤:
sqlite3 <DB filename>
CREATE TABLE IF
NOT EXISTS "django_content_type" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"app_label" varchar(100) NOT NULL,
"model" varchar(100) NOT NULL
);
python manage.py migrate --fake-initial
这应该会按预期运行迁移。关于python - sqlite3.操作错误: no such table: django_content_type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43433406/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!