Bonjour ,
je suis actuellement le livre sur le site officiel djangobook
mais j'ai malheureseument une erreur de type 404 que je n'arrive pas à comprendre

Le fichier urls.py

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
from django.conf.urls.defaults import patterns, include, url
 
from monsite.views import current_datetime
 
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
# current_datetime est passe en tant qu'objet
# r signifie que ^time/$ est une chaine Python brute
#avec ou sans le r avec ou sans le $ le résultat est le même 8O
urlpatterns = patterns('',
    (r'^time/$',current_datetime),
 
    # Examples:
    # url(r'^$', 'monsite.views.home', name='home'),
    # url(r'^monsite/', include('monsite.foo.urls')),
 
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
 
    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)
Le fichier views

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
 
 
#retourne une page html incluant la date et l'heure courante
#2 ligne construit une reponse html
from django.http import HttpResponse
import datetime
 
def current_datetime(request):
    now = datetime.datetime.now()
    html = "<html><body>It is now %s.</body></html>" % now
    return HttpResponse(html)
Merci apparemment cela vient du fichier urls mais il me semble bien?!

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Using the URLconf defined in monsite.urls, Django tried these URL patterns, in this order:
^time/$
The current URL, , didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

Mon post n'est peut être pas au bon endroit je poste chez django