Hello,
the bookp route requires a user and a book_id parameter. Unless you supply
that, your {% url %} tag won't match.
Best,
Gergely
On 27 Sep 2015 12:49, "hossein" <[email protected]> wrote:
> this is my views and url.py
> as long as use <a> tag in my template show error
>
> url
>
> urlpatterns = [
> url(r'^bookee/$', views.index, name='index'),
> url(r'^bookee/user/(?P<user>[a-z0-9-._@+]\w+)/$', views.uprofile,
> name='userprofile'),
> url(r'^bookee/user/(?P<user>[a-z0-9-._@+]\w+)/book/(?P<bookid>\d)/$',
> views.bookprof, name='bookp'),
>
> url(r'^bookee/user/(?P<user>[a-z0-9-._@+]\w+)/publisher/(?P<publishid>\d)/$',
> views.publishprof, name='publishep'),
> ]
>
>
>
> view
>
> def uprofile(request, user):
> usr = User.objects.get(username=user)
> book = Book.objects.filter(user=usr)
> return render(request, 'u/uprof.html', {'usr': usr, 'book': book})
>
> def bookprof(request, user, bookid):
> usr = User.objects.get(username=user)
> bookid = Book.objects.get(id=bookid)
> # bookd = Book.objects.filter(id=bookid)
> return render(request, 'u/uprof.html', {'usr':usr,'bookid': bookid})
>
> def publishprof(request, user, publishid):
> usr = User.objects.get(username=user)
> pubid = Publisher.objects.get(id=publishid)
> publisher = Publisher.objects.filter(id=pubid)
> return render(request, 'u/uprof.html', {'usr':usr,'publisher': publisher})
>
> template
>
> <a href="{% url 'bookp' %}">
> <p>
> list of books
> </p>
> </a>
>
> NoReverseMatch at /bookee/user/admin/
> Reverse for 'bookp' with arguments '()' and keyword arguments '{}' not found.
> 1 pattern(s) tried:
> ['bookee/user/(?P<user>[a-z0-9-._@+]\\w+)/book/(?P<bookid>\\d)/$']
>
>
> thanks for your help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a9092ae0-ff31-467c-ab25-e8418d82270d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a9092ae0-ff31-467c-ab25-e8418d82270d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CACczBUJeMpAy%2Bqm6c0_Z5c3ihTcdT3eGnEnZD8fUMaFHq93DRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.