csev/dj4e-samples

ModuleNotFoundError/ImproperlyConfigured/ModuleError

doublyU opened this issue ยท 1 comments

When tried to import models module to views.py, this way I got_ the error of ImproperlyConfigured.

*from django.shortcuts import render
from models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

This Is the error here below ๐Ÿ‘‡
(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from models import Car
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\models.py", line 4, in
class Car(models.Model):
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\db\models\base.py", line 127, in new
app_config = apps.get_containing_app_config(module)
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\apps\registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\apps\registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\conf_init_.py", line 87, in getattr
self.setup(name)
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\conf_init
.py", line 67, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I tried another way to import it again this way ๐Ÿ‘‡

*from django.shortcuts import render
from .models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

This is the error that I got here ( ImportError: attempted relative import with no known parent package)๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from .models import Car
ImportError: attempted relative import with no known parent package

Lastly I tired to import it this way too ๐Ÿ‘‡

**from django.shortcuts import render
from gview.models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

Here is the error that I got (moduleNotFoundError) ๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from gview.models import Car
ModuleNotFoundError: No module named 'gview'**m .models import Car
ImportError: attempted relative import with no known parent package

Lastly I tired to import it this way too ๐Ÿ‘‡

*from django.shortcuts import render
from gview.models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

Here is the error that I got (moduleNotFoundError) ๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from gview.models import Car
ModuleNotFoundError: No module named 'gview'

Please I need quick response to this
Thanks

csev commented

We do not debug student code here in github.