提问者:小点点

ORA-00918:列定义模糊错误,在从2.0升级到django 3.03后尝试打开django管理页面


找德扬戈。db。乌提尔斯。DatabaseError:ORA-00918:当我试图打开Django管理页面时,列定义模糊的错误。以下是错误:

提高dj_exc_值。使用exc_值文件“/venomscribe/lib/python3.6/site packages/django/db/backends/utils.py”中的第86行的“回溯(traceback)”,执行返回self。光标。执行(sql,params)文件“/venoscribe/lib/python3.6/site packages/django/db/backends/oracle/base.py”,第514行,在执行返回self中。光标。执行(查询,自参数生成器(参数))django。db。乌提尔斯。DatabaseError:ORA-00918:定义不明确的列

疑问是

SELECT "DJANGO_ADMIN_LOG"."ID",
       "DJANGO_ADMIN_LOG"."ACTION_TIME",
       "DJANGO_ADMIN_LOG"."USER_ID",
       "DJANGO_ADMIN_LOG"."CONTENT_TYPE_ID",
       "DJANGO_ADMIN_LOG"."OBJECT_ID",
       "DJANGO_ADMIN_LOG"."OBJECT_REPR",
       "DJANGO_ADMIN_LOG"."ACTION_FLAG",
       "DJANGO_ADMIN_LOG"."CHANGE_MESSAGE",
       "AUTH_USER"."ID",
       "AUTH_USER"."PASSWORD",
       "AUTH_USER"."LAST_LOGIN",
       "AUTH_USER"."IS_SUPERUSER",
       "AUTH_USER"."USERNAME",
       "AUTH_USER"."FIRST_NAME",
       "AUTH_USER"."LAST_NAME",
       "AUTH_USER"."EMAIL",
       "AUTH_USER"."IS_STAFF",
       "AUTH_USER"."IS_ACTIVE",
       "AUTH_USER"."DATE_JOINED",
       "DJANGO_CONTENT_TYPE"."ID",
       "DJANGO_CONTENT_TYPE"."APP_LABEL",
       "DJANGO_CONTENT_TYPE"."MODEL"
  FROM "DJANGO_ADMIN_LOG"
  INNER JOIN "AUTH_USER"
    ON ("DJANGO_ADMIN_LOG"."USER_ID" = "AUTH_USER"."ID")
  LEFT OUTER JOIN "DJANGO_CONTENT_TYPE"
    ON ("DJANGO_ADMIN_LOG"."CONTENT_TYPE_ID" = "DJANGO_CONTENT_TYPE"."ID")
  WHERE "DJANGO_ADMIN_LOG"."USER_ID" = :arg0
  ORDER BY "DJANGO_ADMIN_LOG"."ACTION_TIME" DESC
  FETCH FIRST 10 ROWS ONLY

共2个答案

匿名用户

这是系统需求问题。我使用的是oracle 12.1,它与django 3.0不兼容。3.降级到2.2解决了问题。

匿名用户

您正在获取DJANGO_管理日志。ID,身份验证用户。ID和DJANGO_内容_类型。ID,所以您试图在结果集中有三个ID列。这是不允许的。我建议您为这些列添加别名,以便能够区分它们:

SELECT l.ID AS DJANGO_ADMIN_LOG_ID,
       l.ACTION_TIME,
       l.USER_ID,
       l.CONTENT_TYPE_ID,
       l.OBJECT_ID,
       l.OBJECT_REPR,
       l.ACTION_FLAG,
       l.CHANGE_MESSAGE,
       u.ID AS AUTH_USER_ID,
       u.PASSWORD,
       u.LAST_LOGIN,
       u.IS_SUPERUSER,
       u.USERNAME,
       u.FIRST_NAME,
       u.LAST_NAME,
       u.EMAIL,
       u.IS_STAFF,
       u.IS_ACTIVE,
       u.DATE_JOINED,
       t.ID AS DJANGO_CONTENT_TYPE_ID,
       t.APP_LABEL,
       t.MODEL
  FROM DJANGO_ADMIN_LOG l
  INNER JOIN AUTH_USER u
    ON l.USER_ID = u.ID
  LEFT OUTER JOIN DJANGO_CONTENT_TYPE t
    ON l.CONTENT_TYPE_ID = t.ID
  WHERE l.USER_ID = :arg0
  ORDER BY l.ACTION_TIME DESC
  FETCH FIRST 10 ROWS ONLY

我还建议您使用空白和表别名来使查询更容易阅读。