covici
March 15, 2021, 11:25am
1
Hi folks. My primary interest is to setup the project for mailman3, but their docs don’t have much to say, so I need to learn django a bit.
I started the mysite project, but the runserver is not finding my polls urls, so here is the views.py from my mysite/polls directory
from django.http import HttpResponse
def index(request):
return HttpResponse(“Hello, world. You’re at the polls index.”)
Now here is the urls.py from the same directory
from django.urls import path
from . import views
urlpatterns = [
path(’’, views.index, name=‘index’),
]
Now here is the url.py from the main mysite directory
from django.urls import include, path
from django.contrib import admin
urlpatterns = [
path(‘polls/’, include(‘polls.urls’)),
path(‘admin/’, admin.site.urls),
]
So, I am getting a 404 and it is only searching admin, I am sure I am doing something wrong, but I am not sure what.
Thanks in advance for any suggestions.
What url are you entering that is giving you the 404? (Have you tried “/polls/”?)
covici
March 15, 2021, 1:00pm
3
I am using http://localhost:8000/polls if I just use 8000 I get the
congratulations page.
Notice the trailing ‘/’. Give that a try.
covici
March 15, 2021, 6:35pm
5
You problem is: path(’’ , views.index, name=‘index’),
you are using u02BC - ‘modifier letter apostrophe’
but you should use u0027 - ‘apostrophe’.
Btw. when I am here I have also one question regarding my first project. I have just completed this cool Django introduction and I found small problem in part 6 - https://docs.djangoproject.com/en/3.1/intro/tutorial06
Here is part when I add body background to polls/static/polls/style.css cascade sheet but there is this
small problem - template previously created does not have body tags, so of course its not displaying it. I am not sure where this can be reported, so maybe someone know ?
Or its maybe this forum - doing characters modification