我想在下一页显示这些图像:Django

2024-04-18 08:12:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在下一页打开这些图片

xx

但向我显示此错误:找不到页面

xx

url.py

from django.urls import path,include
from django.conf.urls import url
#from .views import VrPageView
from . import views`

urlpatterns = [
    path('', views.index, name='listings'),
    path('<int:listing_id>', views.listing, name='listing'),
    path('search', views.search, name='search'),
    #path('listings/',VrPageView.as_view(),name='vr.html'),
    path('/<int:listing_id>/vr.html', views.vr, name='vr'),
]

views.py

from django.shortcuts import get_object_or_404, render
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from .choices import price_choices, bedroom_choices, state_choices
from django.views.generic import TemplateView

from .models import Listing

def vr(request,listing_id):
    listing = get_object_or_404(Listing, pk=listing_id)
    context = {'listing': listing}
    return render(request,'listings/vr.html',context)'