0

Note: I have tried the solution from error: ORA-65096: invalid common user or role name in oracle

I am following the tutorial from django a link. When i trying to test the testcase using "py manage.py test polls" i get this:

    C:\Users\user\Documents\user_django_projects\mysite>py manage.py test polls
    Creating test database for alias 'default'...
    Failed (ORA-01543: tablespace 'TEST_SYSTEM' already exists)
    It appears the test database, test_system, already exists. Type 'yes' to delete it, or 'no' to cancel: yes
    Destroying old test database for alias 'default'...
    Creating test user...
    Failed (ORA-65096: invalid common user or role name)
    Got an error creating the test user: ORA-65096: invalid common user or role name

django can't seem to create a temp user on my local oracle express database. Can someone help me sort it out?

DST
  • 71
  • 8
  • @KostasCharitidis Hi, I have seen that but I am unsure what to do to fix the issue. I tried following: 1) Open CMD type sqlplus and hit enter 2) Connect from system login 3) Run command : alter session set "_ORACLE_SCRIPT"=true; – DST Sep 16 '19 at 07:57
  • @KostasCharitidis but it still failed. I am not sure what i need to change in the test class so that when django automated testing fixes it. – DST Sep 16 '19 at 07:59

1 Answers1

1

Connect to sqlplus as sys

sqlplus "sys AS SYSDBA"

Create a PDB account

SQL> alter session set container = XEPDB1;

Session altered.

SQL> create user djangousername identified by djangopassword;

User created.

SQL> grant all privileges to django;

Grant succeeded.

if you using Oracle 12 change XEPDB1 to ORCLPDB

Now you can connect to Database with sqldeveloper with username and password above and enter code hereService Name is XEPDB1 or ORCLPDB

Change your database settings at mysite/mysite/settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'localhost:1521/XEPDB1',
        'USER': 'djangousername ',
        'PASSWORD': 'djangopassword',
    }
}

Now run

python manage.py migrate
python manage.py test polls
Ade
  • 11
  • 1
  • 4