飞翔的彼得猪 发表于 2020-7-31 00:17:34

NOT NULL constraint failed: learning_logs_entry.owner_id

NOT NULL constraint failed: learning_logs_entry.owner_id

Traceback (most recent call last):
File "F:\learning_log\ll_env\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
File "F:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
File "F:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "F:\learning_log\ll_env\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
File "F:\learning_log\learning_logs\views.py", line 61, in new_entry
    new_entry.save()
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\base.py", line 745, in save
    self.save_base(using=using, force_insert=force_insert,
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\base.py", line 782, in save_base
    updated = self._save_table(
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\base.py", line 887, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\base.py", line 924, in _do_insert
    return manager._insert(
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\query.py", line 1204, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
File "F:\learning_log\ll_env\lib\site-packages\django\db\models\sql\compiler.py", line 1392, in execute_sql
    cursor.execute(sql, params)
File "F:\learning_log\ll_env\lib\site-packages\django\db\backends\utils.py", line 100, in execute
    return super().execute(sql, params)
File "F:\learning_log\ll_env\lib\site-packages\django\db\backends\utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "F:\learning_log\ll_env\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
File "F:\learning_log\ll_env\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
File "F:\learning_log\ll_env\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
File "F:\learning_log\ll_env\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
File "F:\learning_log\ll_env\lib\site-packages\django\db\backends\sqlite3\base.py", line 396, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: NOT NULL constraint failed: learning_logs_entry.owner_id

飞翔的彼得猪 发表于 2020-7-31 00:18:45

各位大佬,有没有清楚的,帮忙解答一下

Twilight6 发表于 2020-7-31 00:23:52



没怎么接触 Django 你看看下面的文章能不能帮助到你:

django.db.utils.IntegrityError: NOT NULL constraint failed: blog_blog.author_id的错误解决方法

NOT NULL constraint failed: learning_logs_topic.owner_id


飞翔的彼得猪 发表于 2020-7-31 00:44:22

Twilight6 发表于 2020-7-31 00:23
没怎么接触 Django 你看看下面的文章能不能帮助到你:

django.db.utils.IntegrityError: NOT NULL...

是entry.owner_id出了问题,topic的没有
页: [1]
查看完整版本: NOT NULL constraint failed: learning_logs_entry.owner_id