Hi All
I am using following versions:
Python 3.12.1
Django 5.0.1
Oracle Database 19c
It seems to be a bug in new Django version mentioned above.
I am able to create a new project using django using below steps
-
Create a new Django Project
Django-admin startproject djan_prod_202401 -
Create a new sub app[Module] within main app
python manage.py startapp subapp_202401 -
Create a new Superuser using default sqllite db
python manage.py createsuperuser
User gets create successfully.
Issue starts when I change the default DB connection to my Oracle DB using in settings.py file
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.oracle’,
‘NAME’: ‘DB_NAME’,
‘USER’: ‘DB_USER’,
‘PASSWORD’: ‘DB_PASS’,
‘HOST’: ‘10.xxx.xxx.xxx’,
‘PORT’: ‘1522’,
}
}
After this change, I see that I am able to make DB connection successfully.
PS C:\Python_All\DJANGO_PROJECTS\djan_prod_202401> python manage.py dbshell
SQL*Plus: Release 12.1.0.2.0 Production on Sat Jan 20 14:50:04 2024
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Tue Jan 16 2024 10:59:52 +05:30
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
- After change in DB details make migrations to create tables in Oracle DB
PS C:\Python_All\DJANGO_PROJECTS\djan_prod_202401> python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0002_alter_permission_name_max_length… OK
Applying auth.0003_alter_user_email_max_length… OK
Applying auth.0004_alter_user_username_opts… OK
Applying auth.0005_alter_user_last_login_null… OK
Applying auth.0006_require_contenttypes_0002… OK
Applying auth.0007_alter_validators_add_error_messages… OK
Applying auth.0008_alter_user_username_max_length… OK
Applying auth.0009_alter_user_last_name_max_length… OK
Applying auth.0010_alter_group_name_max_length… OK
Applying auth.0011_update_proxy_permissions… OK
Applying auth.0012_alter_user_first_name_max_length… OK
Applying sessions.0001_initial… OK
PS C:\Python_All\DJANGO_PROJECTS\djan_prod_202401>
After this when I try to create superuser in Oracle DB I get below error.
Password:
Password (again):
Traceback (most recent call last):
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\utils.py”, line 105, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\oracle\base.py”, line 571, in execute
return self.cursor.execute(query, self._param_generator(params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\oracledb\cursor.py”, line 743, in execute
impl.execute(self)
File “src\oracledb\impl/thin/cursor.pyx”, line 173, in oracledb.thin_impl.ThinCursorImpl.execute
File “src\oracledb\impl/thin/protocol.pyx”, line 425, in oracledb.thin_impl.Protocol._process_single_message
File “src\oracledb\impl/thin/protocol.pyx”, line 426, in oracledb.thin_impl.Protocol._process_single_message
File “src\oracledb\impl/thin/protocol.pyx”, line 419, in oracledb.thin_impl.Protocol._process_message
oracledb.exceptions.IntegrityError: ORA-01400: cannot insert NULL into (“DB_USER”.“AUTH_USER”.“IS_STAFF”)
Help: https://docs.oracle.com/error-help/db/ora-01400/
The above exception was the dDB_USERt cause of the following exception:
Traceback (most recent call last):
File “C:\Python_All\DJANGO_PROJECTS\djan_prod_202401\manage.py”, line 22, in
main()
File “C:\Python_All\DJANGO_PROJECTS\djan_prod_202401\manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management_init_.py”, line 442, in execute_from_command_line
utility.execute()
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management_init_.py”, line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py”, line 412, in run_from_argv
self.execute(*args, **cmd_options)
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py”, line 88,
in execute
return super().execute(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py”, line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py”, line 237, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\models.py”, line 172, in create_superuser
return self._create_user(username, email, password, **extra_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\models.py”, line 155, in _create_user
user.save(using=self._db)
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\auth\base_user.py”, line 77, in save
super().save(*args, **kwargs)
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py”, line 822, in save
self.save_base(
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py”, line 909, in save_base
updated = self._save_table(
^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py”, line 1067, in _save_table
results = self._do_insert(
^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\base.py”, line 1108, in _do_insert
return manager._insert(
^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\manager.py”, line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\query.py”, line 1845, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\sql\compiler.py”, line 1823, in execute_sql
cursor.execute(sql, params)
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\utils.py”, line 122, in execute
return super().execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\utils.py”, line 79, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\utils.py”, line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\utils.py”, line 100, in _execute
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\backends\oracle\base.py”, line 571, in execute
return self.cursor.execute(query, self._param_generator(params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\my_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\oracledb\cursor.py”, line 743, in execute
impl.execute(self)
File “src\oracledb\impl/thin/cursor.pyx”, line 173, in oracledb.thin_impl.ThinCursorImpl.execute
File “src\oracledb\impl/thin/protocol.pyx”, line 425, in oracledb.thin_impl.Protocol._process_single_message
File “src\oracledb\impl/thin/protocol.pyx”, line 426, in oracledb.thin_impl.Protocol._process_single_message
django.db.utils.IntegrityError: ORA-01400: cannot insert NULL into (“DB_USER”.“AUTH_USER”.“IS_STAFF”)
Help: ORA-01400 - Database Error Messages
PS C:\Python_All\DJANGO_PROJECTS\djan_prod_202401>