当我尝试访问帖子模型的详细信息页面时,收到该错误。 URL文件中有子弹字段,但这似乎无关紧要。
型号
TYPE_STATUS = (
('post', 'Post'),
('page', 'Page'),
('media', 'Media'),
('menu', 'Menu'),
)
class Post(models.Model):
title = models.CharField(max_length=70)
slug = models.SlugField(blank=True, unique=True)
type_status = models.CharField(max_length=70, default='post',
choices=TYPE_STATUS)
description = models.TextField()
short_description = models.CharField(max_length=155)
image = models.ImageField(upload_to=upload_image_path, null=True, blank=True)
active = models.BooleanField(default=True)
timestamp = models.DateTimeField(auto_now_add=True)
featured = models.BooleanField(default=False)
查看
from django.views.generic import DetailView
from django.shortcuts import render
from posts.models import Post
class home_page(DetailView):
queryset = Post.objects.filter(slug='home', featured=True)
template_name = "home_page.html"
网址
from .views import home_page
urlpatterns = [
url(r'^(?P<slug>[\w-]+)/$', home_page.as_view(), name='home'),
]
答案 0 :(得分:0)
像这样更改您的网址
DetailView
然后确保您的CBV $file="C:\logtest\log-3.json"
add-type -path "C:\logtest\Newtonsoft.Json.dll"
$sr=new-object system.IO.StreamReader($file)
$reader=new-object Newtonsoft.Json.JsonTextReader($sr)
$analyzer=New-Object Newtonsoft.Json.JsonSerializer
$analyzer.ReferenceLoopHandling=[Newtonsoft.Json.ReferenceLoopHandling]::Ignore
$i=0
$n=0
while($reader.read()){
if($n -gt 2){
if($reader.TokenType.ToString() -eq "StartObject"){
$single=$null
$single=$analyzer.Deserialize($reader)
# Deal with the json record...
$i++
}
}
$n++
}
$reader.Close()
中的queryset中有一个值