Use http://localhost:8000/polls/ to view your page.
First urls.py is project file : mysite/mysite/urls.py
urlpatterns = [url(r'^polls/', include('polls.urls')),url(r'^admin/', admin.site.urls),]
Django remove "http://localhost:8000/" in url and search 'polls/' in the project file, It find that '^polls' match so it include polls.urls
mysite/polls/urls.pyfrom . import views
urlpatterns = [url(r'^$', views.index, name='index'),]
Django remove 'polls/' and search '' (empty string) in the polls file, it find '^$' match and use view.index
Regards,
On 27 Jul 2017, at 14:06, Carrie Gardner <carriegardner428@gmail.com> wrote:When I go to localhost:8000/ I get a 404 error. I've been following the intro tutorial, https://docs.djangoproject.com/en/1.11/intro/tutorial01/ and my django version is 1.11.3mysite/polls/urls.py
from . import viewsurlpatterns = [url(r'^$', views.index, name='index'),]
mysite/mysite/urls.py
from django.conf.urls import include, urlfrom django.contrib import adminurlpatterns = [url(r'^polls/', include('polls.urls')),url(r'^admin/', admin.site.urls),]mysite/polls/views.py
from django.http import HttpResponsedef index(request):return HttpResponse("Hello, world. You're at the polls index.")
mysite/mysite/settings.py
"""Django settings for mysite project.Generated by 'django-admin startproject' using Django 1.11.3.For more information on this file, seeFor the full list of settings and their values, see"""import os# Build paths inside the project like this: os.path.join(BASE_DIR, ...)BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# Quick-start development settings - unsuitable for production# SECURITY WARNING: keep the secret key used in production secret!SECRET_KEY = 'sqi%b$@q$lbcmkue+vo0r51d-s=!r9^2l%-m2x&fl4t7p_^1$w'# SECURITY WARNING: don't run with debug turned on in production!DEBUG = TrueALLOWED_HOSTS = []# Application definitionINSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','polls.apps.PollsConfig',]MIDDLEWARE = ['django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]ROOT_URLCONF = 'mysite.urls'TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [],'APP_DIRS': True,'OPTIONS': {'context_processors': ['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},},]WSGI_APPLICATION = 'mysite.wsgi.application'# DatabaseDATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3','NAME': os.path.join(BASE_DIR, 'db.sqlite3'),}}# Password validationAUTH_PASSWORD_VALIDATORS = [{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',},{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',},{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',},{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',},]# InternationalizationLANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True# Static files (CSS, JavaScript, Images)STATIC_URL = '/static/'--
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-users@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/d3dc5304-d7ef-4726-8daa-4a6604cd720e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment