Hello I’m an 11 year old boy who looking to learn python and django. I have been trying this many times but I keep receiving this error it seems to be coming from this URL file
"""
URL configuration for demo project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import include
urlpatterns = [
path('admin/', admin.site.urls),
path("myapp/", include("myapp.urls"))
]
myapp/home
This is the error is keep receiving:
Traceback (most recent call last):
File "/Users/kevin/code/django/demo/myapp/urls.py", line 2, in <module>
from . import views
ImportError: attempted relative import with no known parent package
kevin@Jaspers-MBP-2016 django % /usr/local/opt/pytho
n@3.10/libexec/bin/python /Users/kevin/code/django/d
emo/demo/settings.py
kevin@Jaspers-MBP-2016 django % /usr/local/opt/pytho
n@3.10/libexec/bin/python /Users/kevin/code/django/d
emo/demo/settings.py
kevin@Jaspers-MBP-2016 django % /usr/local/opt/pytho
n@3.10/libexec/bin/python /Users/kevin/code/django/d
emo/myapp/urls.py
Traceback (most recent call last):
File "/Users/kevin/code/django/demo/myapp/urls.py", line 2, in <module>
from . import views
ImportError: attempted relative import with no known parent package
kevin@Jaspers-MBP-2016 django % /usr/local/opt/pytho
n@3.10/libexec/bin/python /Users/kevin/code/django/d
emo/demo/urls.py
Traceback (most recent call last):
File "/Users/kevin/code/django/demo/demo/urls.py", line 22, in <module>
path('admin/', admin.site.urls),
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 251, in inner
self._setup()
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/sites.py", line 605, in _setup
AdminSiteClass = import_string(apps.get_app_config("admin").default_site)
File "/usr/local/lib/python3.10/site-packages/django/apps/registry.py", line 156, in get_app_config
self.check_apps_ready()
File "/usr/local/lib/python3.10/site-packages/django/apps/registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 81, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 61, 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.
kevin@Jaspers-MBP-2016 django % /usr/local/opt/pytho
n@3.10/libexec/bin/python /Users/kevin/code/django/d
emo/demo/settings.py
kevin@Jaspers-MBP-2016 django % /usr/local/opt/pytho
n@3.10/libexec/bin/python /Users/kevin/code/django/d
emo/demo/urls.py
Traceback (most recent call last):
File "/Users/kevin/code/django/demo/demo/urls.py", line 22, in <module>
path('admin/', admin.site.urls),
File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 251, in inner
self._setup()
File "/usr/local/lib/python3.10/site-packages/django/contrib/admin/sites.py", line 605, in _setup
AdminSiteClass = import_string(apps.get_app_config("admin").default_site)
File "/usr/local/lib/python3.10/site-packages/django/apps/registry.py", line 156, in get_app_config
self.check_apps_ready()
File "/usr/local/lib/python3.10/site-packages/django/apps/registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 81, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.10/site-packages/django/conf/__init__.py", line 61, 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.
If you want to see the full code it’s here GitHub - kevin2e754swap/Django-Cms