css - 导航栏按钮一键失效
问题描述
我创建了博客表单......突然我注意到导航栏/菜单栏中的博客按钮有问题。单击“博客”按钮后,它会变得功能失调。那就是我只能点击一次。
如果我输入网址“..../blog”,我可以访问该页面。
我尝试在 blog.url 之前添加我的应用程序名称,因为我有一些线程提出了它。它没有用。我删除了迁移,从头开始再次创建博客应用程序......同样的想法发生了。我可以假设它与 project/urls.py 或菜单栏有关。我重新输入了所有代码......我仍然有这个问题。
与往常一样,我们非常感谢任何输入!
这是一个 Youtube 短片,可以更好地可视化我的问题。 blogButton 问题 以下是一些代码以防万一:
博客/urls.py:
from django.urls import path
from .views import (
PostListView,
PostDetailView,
PostCreateView,
PostUpdateView,
PostDeleteView
)
from . import views
urlpatterns = [
path('', PostListView.as_view(), name='blog_index'),
path('post/<int:pk>/', PostDetailView.as_view(), name='post_detail'),
path('post/new/', PostCreateView.as_view(), name='post-create'),
path('post/<int:pk>/update/', PostUpdateView.as_view(), name='post-update'),
path('post/<int:pk>/delete/', PostDeleteView.as_view(), name='post-delete'),
path("<category>/", views.blog_category, name="blog_category"),
项目/urls.py:
path('accounts/', include('django.contrib.auth.urls')),
path('blog/', include('blog.urls')),
path('about/', include('about.urls'))
导航栏.html:
博客 <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 js-scroll-trigger {% if request.path == contact_url %} active {%endif%}" href="{{ contact_url }}">Contact</a></li>
{% if user.is_authenticated %}
视图.py:
class PostListView(ListView):
model = Post
template_name = 'blog/blog_index.html' # <app>/<model>_<viewtype>.html
context_object_name = 'posts'
ordering = ['-created_on']
blog_index.html:
,
解决方案
推荐阅读
- c# - MessageBox.Show 显示太快
- hybris - Hybris PCM 产品类别限制
- elasticsearch - Elasticsearc 查询数组字段并匹配数组中的确切一个对象
- ansible - 如何在ansible playbook中循环变量
- correlation - scRNA-seq 中的肿瘤异质性 - 细胞间相关性
- azure - Azure DevOps:如何仅将权限限制为板?
- c# - 使用来自 API 的数据填充组合框
- mysql - 如何在多对多表关系中优化查询性能
- sql - 将 nvarchar 值“”转换为数据类型 int 时 SQL Server 数据库错误转换失败
- powershell - PowerShell 为 cmdlet 实现 -AsJob