0
0 комментариев

Здравствуйте, не могу разобраться в чем причина ошибки:

«^?P[\w-]+/$» is not a valid regular expression: nothing to repeat

project/urls.py

url(r'^blog/', include('blog.urls')),

app/urls.py

from django.conf.urls import patterns, url
 
urlpatterns = patterns('',
                       url(r'^$', 'blog.views.blog', name='blog'),
                       url(r'^?P<slug>[\w-]+/$', 'blog.views.blog_detail', name='blog_detail'),
                       )

app/views.py

from django.shortcuts import get_object_or_404, render
from blog.models import BlogDjango
 
 
def blog(request):
    blog_list = BlogDjango.objects.all()
    return render(request, 'blog.html', {'blog_list': blog_list})
 
 
def blog_detail(request, slug):
    blog = get_object_or_404(BlogDjango, slug=slug)
    return render(request, 'post.html', {'blog': blog})

blog.html

<a href="{% url 'blog_detail' slug=blog_list.slug %}">{{ db.blog_title }}/a>


Добавить комментарий