I know this question has been asked before, but I haven't found an answer that solves my situation. I'm looking at the Django tutorial, and I've set up the first URLs exactly as the tutorial has it, word for word, but when I go to http://http://loca

33 views
Skip to first unread message

Avitab Ayan Sarmah

unread,
Apr 22, 2018, 1:23:58 PM4/22/18
to Django users
polls/views.py
from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

polls/urls.py
from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),
]

mysite/urls.py
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]

vikramch...@gmail.com

unread,
Apr 22, 2018, 3:12:07 PM4/22/18
to Django users
 I have made few changes take a look at it and try this one. I hope this will work.


On Sunday, April 22, 2018 at 10:53:58 PM UTC+5:30, Avitab Ayan Sarmah wrote:
polls/views.py
from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

polls/urls.py
from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]

mysite/urls.py
from django.contrib import admin
from django.conf.urls import include, url

urlpatterns = [
    url(r'', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

Emma Amechu

unread,
Apr 23, 2018, 7:33:01 AM4/23/18
to django...@googlegroups.com
Hi Vikram, 

Am also a few days new into Django but if you are using Python 3, then I suggest you try without the regular expressions. Update your URLs to the below and try loading your sites. 

polls/urls.py
from django.conf.urls import url

from . import views

urlpatterns = [
    url('', views.index, name='index'),
]

mysite/urls.py
from django.contrib import admin
from django.conf.urls import include, url

urlpatterns = [
    url('', include('polls.urls')),
    url('admin', admin.site.urls),
]
Regards
Emma

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fcc6b586-8ab1-4886-9e59-ba4a3d75c3aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Reply all
Reply to author
Forward
0 new messages