2 Replies Latest reply on Apr 5, 2019 4:53 AM by 3531913

    Unable to connect to Django with oracle database

    3531913

      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