Answer the question
In order to leave comments, you need to log in
Why don't links work in Django in header?
About rendering in one case everything is OK, in another with a similar template - the links are silent.
This is how I try to redirect to the page after filling out the feedback form on the landing page.
Tell me where to look and where to look?
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="/#home">Home</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/#home">Главная <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/#blog">Статьи</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/#contact">Контакты</a>
</li>
</ul>
<!--
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
-->
</div>
</nav>
</header>
def post_list(request):
posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')[0:3]
if request.method == 'POST':
f = FeedbackForm(request.POST)
if f.is_valid():
f.save()
return render(request, 'blog/feedback.html') #### НЕ РАБТАЕТ
else:
f = FeedbackForm()
return render(request, 'blog/post_list.html', {'posts': posts, 'form': f})
def post_detail(request, pk): ### ВСЕ ОК
post = get_object_or_404(Post, pk=pk)
return render(request, 'blog/article.html', {'post': post})
app_name = "blog"
urlpatterns = [
path('', views.post_list, name='post_list'),
url(r'^api/article/(?P<pk>[0-9]+)/$', views.post_detail, name='post_detail'),
url(r'^feedback/$', views.feedback, name='feedback'),
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question