Они наслаиваются примерно вот так:
127.0.0.1:8000/post/6/post/5/post/4/post/3/post/2/...
Как это исправить ?
Я не знаю какой код прислать поэтому пришлю всё, в чём я сомневаюсь.
urlpatterns = [
url(r'^$', views.index, name="index"),
url(r'post/(?P<index>[0-9]+)/$', views.post),
url(r'login/$', views.login),
url(r'signup/$', views.signup),
url(r'signup_user/$', views.signup_user, name="signup_user"),
url(r'check_user_name/$', views.check_user_name, name="check_user_name")
]
def post(request,index):
try:
test = Post.objects.get(id=index)
previous_id = test.id - 1
next_id = test.id + 1
context = {
"test": test,
"previous_id": previous_id,
"next_id": next_id,
"max_id": len(Post.objects.all())
}
return render(request, "post.html", context)
except Post.DoesNotExist:
return render(request, "error_page.html")
{% extends "index.html" %}
{% load bootstrap3 %}
{% block bootstrap3_content %}
<nav class="navbar navbar-default navbar-fixed-top" style="...">
<div class="container">
<div class="navbar-header">
<span>
<a class="navbar-brand"><i class="fa fa-newspaper-o "></i>RSS News</a>
</span>
</div>
<div class="navbar-right">
<div class="navbar-text"><a class="btn btn-default btn-xs" href="/signup">signup</a> </div>
<div class="navbar-text"><a class="btn btn-default btn-xs"href="/login">Log in</a></div>
</div>
</div>
</nav>
<div class="container" style="margin-top: 100px;">
<div class="row">
<div class="col-xs-12 text-left">
<h1>{{ test.title }}</h1>
</div>
</div>
<div class="row">
<div class="col-xs-12 text-left">
<div class="btn-group">
<a class="btn btn-sm btn-default" href="post/{{ previous_id }}" ><i class="fa fa-arrow-left"></i> Previous post</a>
<a class="btn btn-sm btn-default" href="post/{{ next_id }}"> Next post <i class="fa fa-arrow-right"></i></a>
</div>
</div>
</div>
</div>
{% endblock %}