K
K
kopelev20002018-07-02 20:01:37
Django
kopelev2000, 2018-07-02 20:01:37

Does not find the application and writes "page not found". What to do?

I write in advance that so far only a teapot and did everything according to the guide, but nothing happened.
Here's the problem.

spoiler
5b3a573a172ad151629161.png
Вроде, всё указал.
5b3a5901e8cae064902670.png
5b3a5978d04dd852887938.png
views в приложении:
5b3a59edda5f8212473163.png
Вот urls в webexamples:
5b3a5a4216af7046938734.png

INSTALLED_APPS = [
'webexample',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path(r'^admin/',admin.site.urls),
path(r'^webexample/', include('webexample.urls')),
]
Urls приложения:
from django.urls import path
from . import views

urlpatterns = [
path('', views.index, name ='index'),
]
Views приложения:
from django.shortcuts import render
from django.http import HttpResponce

def index(request):
return HttpResponce(" LLLLLLLLLLLLLL ")

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SlonPC, 2018-07-06
@kopelev2000

if it's django >2, then you shouldn't use regular expressions in path(), that's what re_path is for.
try:
1. Replace regular expressions in project URLs with regular strings:
urlpatterns = [
path( 'admin/' ,admin.site.urls),
path( 'webexample/' , include('webexample.urls')),
]
2. Move your app to the end of INSTALLED_APPS

T
Tim, 2018-07-04
@darqsat

I'm not a super master but I think that urls never end with a slash. Remove the slash at the end of the webexample url. It works with admin urls because there is no index there. It seems that the admin panel by default throws on admin / pages or something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question