注册

来源:5-3 用户登录-注册-注销-找回密码

JackCai20

2021-03-22

MySQLdb._exceptions.OperationalError: (1054, "Unknown column 'first_name' in 'field list'")

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

Traceback (most recent call last):
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/python3/lib/python3.7/contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/utils/decorators.py", line 45, in _wrapper
    return bound_method(*args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/views.py", line 214, in dispatch
    return super(SignupView, self).dispatch(request, *args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/views.py", line 80, in dispatch
    **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/views.py", line 192, in dispatch
    **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/views.py", line 103, in post
    response = self.form_valid(form)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/views.py", line 230, in form_valid
    self.user = form.save(self.request)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/forms.py", line 404, in save
    adapter.save_user(request, user, self)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/allauth/account/adapter.py", line 243, in save_user
    user.save()
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 73, in save
    super().save(*args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/base.py", line 718, in save
    force_update=force_update, update_fields=update_fields)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/base.py", line 748, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/base.py", line 831, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/base.py", line 869, in _do_insert
    using=using, raw=raw)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/query.py", line 1136, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql
    cursor.execute(sql, params)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/root/.virtualenvs/zanhu01/lib/python3.7/site-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1054, "Unknown column 'first_name' in 'field list'")
[22/Mar/2021 15:13:52] "POST /accounts/signup/ HTTP/1.1" 500 255901

我输入邮箱,密码之后,点击注册报错了
图片描述

图片描述

写回答

2回答

鲨鱼辣椒辣

2021-03-23

是不是数据库不存在这个字段,你重新生成一下试试

1
2
JackCai20
谢谢,我已经重新生成了一边数据库
2021-03-24
共2条回复

Jack

2021-03-23

Unknown column 'first_name' in 'field list

看报错意思,是数据表里没这个字段吧

0
0

Django高级实战 开发企业级问答网站

融合Django高级用法/算法/设计模式/TestCase测试/云计算打造项目

900 学习 · 756 问题

查看课程