Django-fr

Forum

#1 21-07-2011 18:08:13

pit0n
Membre
Inscription : 21-07-2011
Messages : 1

Page 404 djangobook

Bonjour,


Mon erreur sur le serveur

Page not found (404)
Request Method:    GET
Request URL:    http://127.0.0.1:8000/time
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.


Il suffisait que je tape la bonne url hum !

Merci Florient tu a répondu de manière synchrone smile

Dernière modification par pit0n (21-07-2011 18:54:44)

Hors ligne

#2 21-07-2011 18:49:38

Florian Strzelecki
Membre
Inscription : 11-08-2010
Messages : 40

Re : Page 404 djangobook

Bonsoir,

Essaye l'url suivante (après avoir lancé ton serveur de dev) :
http://127.0.0.1:8000/time/
Tu noteras d'ailleurs qu'en allant à la même URL sans le / final, tu
obtiendras (normalement) une erreur.

Le principe de l'urlpatterns, c'est d'avoir une liste de correspondance :
chemin -> vue.
Si tu ne déclares aucun chemin pour le /, alors il n'y a... aucune vue
associée !

Pour la page "index" c'est à dire le simple /, j'utilise ceci dans mon
urlpatern : (r'^$', 'monapp.views.index')
Par ailleurs, si tu souhaites laisser le / final optionnel sur tes autres
URLs, tu as plusieurs possibilités, dont mettre "/?$" à la place de "/$".
Une autre possibilité est de configuré je-ne-sais-plus-quoi pour que Django
ajoute automatiquement le / à la fin (de mémoire, avec une redirection).

Voilà voilà. Bon courage !
Florian.


2011/7/21 greg <nik0p0l _AT_ live.fr>

> Bonjour,
>
> Mon fichier urls.py
>

> from django.conf.urls.defaults import *
> from monsite.views import current_datetime
>
> urlpatterns = patterns('',
>    (r'^time/$', current_datetime),
> )
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
>
>    # 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)),
>
>

> Mon fichier views.py
>
>

> #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)
>
>

> Mon erreur sur le serveur (incompréhensible car pourtant le même)
>

> Page not found (404)
> Request Method: GET
> Request URL:    [url]http://127.0.0.1:8000[/url]/
> 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.
>

>
> Merci pour vos réponses .
> _______________________________________________
> django mailing list
> django _AT_ lists.afpy.org
> http://lists.afpy.org/mailman/listinfo/django
>

Hors ligne

Pied de page des forums