django - Django 2.1.1 'set' 对象不可逆'set' 对象是
问题描述
商店/网址
#/shop/
from django.urls import path`enter code here
from . import views
app_name='shop'
urlpatterns = [
path('', views.allProdCat, name='allProdCat'),
path('<slug:c_slug>/', views.allProdCat, name='products_by_category'),
path('<slug:c_slug>/<slug:product_slug>/', views.ProdCatDetail, name='ProdCatDetail'),
]
商店/模板/商店/标题
{% load staticfiles %}
<header>
<center>
<a href="{% url 'shop:allProdCat' %}"><img class ='zapp-logo' src="{% static 'img/zapp_banner.jpg' %}" alt="Logo "></a>
</center>
</header>
经过一些搜索,没有找到任何解决方案。有谁知道这个问题?
from django.contrib import admin
from django.urls import path, include
from shop import views
from django.conf import settings
from django.conf.urls.static import static
编辑 :
main/shop/templates/shop/base.html(标题扩展自)
{% load staticfiles %}
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="{% block metadescription %}{% endblock %}">
<link rel="stylesheet" href="{% static 'css/custom.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/all.css' %}">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div class='container'>
{% include 'shop/header.html' %}
{% include 'shop/navbar.html' %}
{% block content %}
{% endblock %}
</div>
{% include 'shop/footer.html' %}
<script src="{% static 'js/jquery-3.3.1.slim.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
</body>
</html>
主要/网址
urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('shop.urls')),
path('cart/', include('cart.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
主要/设置(某些部分)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'shop',
'cart',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'shop', 'templates/'), os.path.join(BASE_DIR, 'cart', 'templates/')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'shop.context_processor.menu_links'
],
},
},
]
解决方案
推荐阅读
- docker - 在 Dockerfile 中定义一个语言环境变量
- batch-file - 7zip 批处理脚本在带有感叹号的文件夹上中断
- python - 在 Python 中按字符迭代字符串列表
- sqlalchemy - sqlalchemy - 使用字典创建表
- c - c中的帕斯卡三角形没有数组
- python - 替换文件python中每一行的第一个字符
- wordpress - 如何将自定义字段添加到古腾堡自定义格式?
- python - 当我使用 sin 函数时,“只有 size-1 数组可以转换为 Python 标量”
- django - 渲染()缺少 1 个必需的位置参数:“数据”
- azure - Azure 资源组和资源部署到相同位置