Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Unable to connect to Django with oracle database

Mohit YadavApr 4 2019 — edited Apr 5 2019

Hi all,

I'm trying to build my first web application using Django.

I'm actually referring to Using Python With Oracle Database 11g (under the section 'Using the Django Framework')

Steps followed

1. django-admin.py startproject myproj

2. cd myproj

3. python manage.py startapp myapp

4. Once the above commands were executed successfully, the next step was to modify the connection settings to allow the application to connect to the database in the file myproj/settings.py.

Here i updated the details with our database details

DATABASES = {

'default': {

    'ENGINE': 'django.db.backends.oracle',

    'NAME': '\<our ebs database name>',

'USER': <username>,

'PASSWORD': <password>,

}

}

5. Also added the project under the INSTALLED_APPS to associate the application with the project:

INSTALLED_APPS = [

'django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'django.contrib.staticfiles',

'myproj.myapp'

]

6. In a terminal window when i try to execute the below command from myproj directory:

python manage.py runserver

I'm getting the below error message

C:\Users\xxx\Desktop\Python files\myproj>python manage.py runserver

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000274CA28AEA0>

Traceback (most recent call last):

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 118, in create

cls = getattr(mod, cls\_name)

AttributeError: module 'myproj' has no attribute 'myapp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper

fn(\*args, \*\*kwargs)

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run

autoreload.raise\_last\_exception()

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception

raise \_exception\[1\]

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 337, in execute

autoreload.check\_errors(django.setup)()

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper

fn(\*args, \*\*kwargs)

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup

apps.populate(settings.INSTALLED\_APPS)

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 89, in populate

app\_config = AppConfig.create(entry)

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 123, in create

import\_module(entry)

File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module

return \_bootstrap.\_gcd\_import(name\[level:\], package, level)

File "<frozen importlib._bootstrap>", line 1006, in _gcd_import

File "<frozen importlib._bootstrap>", line 983, in _find_and_load

File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'myproj.myapp'

django error.PNG

Hoping someone can help me on how to rid of this error

Comments

Processing

Post Details

Added on Apr 4 2019
2 comments
2,676 views