i am very new to Django, just trying out with a url to a view structure basically this:
test\
project-level files + templates
newyear\
app files + templates
manage.py
on newyear urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
]
on views.py
from django.shortcuts import render
import datetime
# Create your views here.
def index(request):
now = datetime.datetime.now()
return render(request, 'newyear/index.html', {
"newyear": now.month == 1 and now.day == 1
})
on urls.py in test
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('newyear/', include('newyear.urls')),
path('admin/', admin.site.urls),
]
on settings in test
INSTALLED_APPS = [
'newyear',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
I have rerun the server but still only recognizes /admin, please help thanks
You may have to set your
app_namein your newyear urls.py. it should look like this: