2015-12-26 12 views
0

Я новый с Django, у меня проблема с URL страницы «DetailLivre.html» показывает:Django шаблон URL не совпадает с моей конфигурации

Использование URLconf определено в Ilhem.urls, Джанго попытался эти шаблоны URL, в следующем порядке:.

^Bibliotheque/ ^$ [name='index'] 
^Bibliotheque/ ^(?P<livre_id>[0-9]+)/$ [name='DetailLivre'] 
^admin/ 

текущий URL, Bibliotheque/BOOK1/, не соответствуют ни одному из них *

Я использую: Python 2.7.6, django 1.8.5 пожалуйста, вы можете помочь ?

index.html:

<h1>La liste des Livres </h1> 
 
    
 
{% block content %} 
 
    {% block theme %} 
 
    {% load bootstrap_themes %} 
 
    {% bootstrap_styles theme='default' type='min.css' %} 
 
    {% bootstrap_styles theme='cosmo' type='css' %} 
 
    {% bootstrap_styles theme='united' type='less' %} 
 
    {% bootstrap_script use_min=True %} 
 
    {% endblock theme %} 
 
{% if BookList%} 
 
<div class="container-fluid"> 
 
    <div class="row"> 
 
    <ul> 
 
    {% for livre in BookList %} 
 
     <li><a href="/Bibliotheque/{{ livre.Titre }}/">{{ livre.Titre }}</a></li> 
 
    {% endfor %} 
 
    </ul> 
 
    </div> 
 
</div> 
 
{% else %} 
 
    <p>Pas de Livres.</p> 
 
{% endif %} 
 
{% endblock %}

DetailLivre.html

<h1>{{ Auteur }}</h1> 
 

 
<label for="Nom">{{ Auteur.Nom }}</label><br /> 
 
<label for="Prenom">{{ Auteur.Prenom }}</label><br /> 
 
<label for="dateNaissance">{{ Auteur.dateNaissance }}</label><br /> 
 
<label for="Lieu_de_naissance">{{ Auteur.Lieu_de_naissance }}</label><br /> 
 
<label for="Specialite">{{ Auteur.Specialite }}</label>

Views.py

 
 
from django.shortcuts import render 
 
from django.template import RequestContext, loader 
 
from django.http import HttpResponse 
 
from django.template import RequestContext, loader 
 
from django.shortcuts import get_object_or_404, render 
 
from .models import Livre, Auteur 
 

 
def index(request): 
 
    
 
    BookList = Livre.objects.all() 
 
    template = loader.get_template('Bibliotheque/index.html') 
 
    context = RequestContext(request, { 
 
     'BookList': BookList, 
 
    }) 
 
    return HttpResponse(template.render(context)) 
 

 
def DetailLivre(request, livre_id): 
 
livre = Livre.objects.get(pk=livre_id) 
 
return render(request, 'Bibliotheque/DetailLivre.html', {'livre.Titre': livre.Titre}) 
 

url.py

from django.conf.urls import url 
 

 
from . import views 
 

 
urlpatterns = [ 
 
    url(r'^$', views.index, name='index'), 
 
    url(r'^(?P<livre_id>[0-9]+)/$', views.DetailLivre, name='DetailLivre'), 
 
]

ответ

0

лет u упустили префикс BOOK BOOK(?P<livre_id>[-\d]+)

Смежные вопросы