Andromedae93 Andromedae93 - 2 months ago 7
Python Question

Page not found (404) with Django

I'm learning Django Framework and I'm following a tutorial based on Django 1.8.
I have Django 1.10 on my Mac OSX and I get an error :

Page not found


I started a project which is named
"Crepes_bretonnes"
and I created an app :
"Blog"
.

The blog urls.py looks like :

from django.conf.urls import url
from django.contrib import admin
from blog.views import home

urlpatterns = [
url(r'^accueil/$', home),
]


The blog views.py looks like :

#-*- coding: utf-8 -*-

from django.shortcuts import render
from django.http import HttpResponse # Ce module permet de retourner une réponse (texte brute, HTML, JSON, ...) depuis une string

# Create your views here.

def home(request) :

text = """<h1>Bienvenue sur mon blog ! </h1>
<p> Edité sous Django 1.10 </p>"""
return HttpResponse(text)


And the crepes_bretonnes urls.py looks like :

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
url(r'^blog/', include('blog.urls'))
]


However, when I'm running the server, I get this error (picture) and I don't understand why it's not working :/

enter image description here

As I said, I'm beginning Django so if anyone can explain me the problem ?

Thank you !

Answer

Your crepes_bretonnes urls are including blog urls, so your blog urls are only visible from blog/ url.

If you want to get to your view you need to open this url:

/blog/accueil/