I am a Python novice and I am trying to run a Django hello world app on Windows. The upper error message shows up with the following code:
import os
import sys
import site
from django.core.wsgi import get_wsgi_application
from django.conf import settings
from django.urls import path
from django.http import HttpResponse
site.addsitedir("C:/Program files/python312/Lib/site-packages")
sys.path.append('C:/Users/felhasznalo/Desktop/django')
sys.path.append('C:/Users/felhasznalo/Desktop/django/todo')
settings.ROOT_URLCONF=__name__
settings.ALLOWED_HOSTS = ['localhost', '127.0.0.1']
settings.SECRET_KEY = '1234'
def hello(request):
return HttpResponse("Hello World!")
urlpatterns = [
path("", hello)
]
application = get_wsgi_application()
I checked a bunch of similar questions, but none of the answers appear to fix this. Any idea what to do or how to debug this? I have the urlpatterns variable present, the hello is a function, the “” is a valid path, still it does not seem to find the variable… :S :S :S I wonder why it uses global variables though instead of argument passing. Does not seem to be a well designed framework…