I have been learning python for some time now and I want to make one of my small programs available to more people. I am learning how to make URLs for my project now and I cannot create a URL for a homepage. As I found in one of the courses for older django version, you should create a function in your urls.py file that looks like this:
from django.http import HttpResponse
def home(request):
return HttpResponse('this is the test homepage')
and pair it with some lines in views.py:
path('^$', views.home)
This doesn't work for me. I also tried to create a path like this:
path('/', views.home)
Please, help or direct me to up to date guides for django 3.1.1.
EDIT in response to @pygeek's request:
the content of my urls.py:
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('about/', views.about),
path('/', views.home)
]
the contents of my apps array in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
And the project tree:
.
└── RemoveBigFile
├── RBF1module
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── RemoveBigFile
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-38.pyc
│ │ ├── settings.cpython-38.pyc
│ │ ├── urls.cpython-38.pyc
│ │ ├── views.cpython-38.pyc
│ │ └── wsgi.cpython-38.pyc
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
├── RemoveBigFile.sublime-project
├── RemoveBigFile.sublime-workspace
├── db.sqlite3
└── manage.py