小编Han*_* Ry的帖子

创建与明细视图相反的视图

上传图像后,我试图从CreateView转换为DetailView。

我收到相同的消息

/ photo / image / add处的NoReverseMatch找不到带有参数'()'和关键字参数'{'pk':50}'的'image-view'反向。尝试了0个模式:[]

这是我的形象模特

from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from django.conf import settings
from string import join
import os

class Image(models.Model):
    title = models.CharField(max_length=60, blank=True, null=True)
    image = models.FileField(upload_to="images/")
    tags = models.ManyToManyField(Tag, blank=True)
    albums = models.ManyToManyField(Album, blank=True)
    created = models.DateTimeField(auto_now_add=True)
    rating = models.IntegerField(default=50)
    width = models.IntegerField(blank=True, null=True)
    height = models.IntegerField(blank=True, null=True)
    user = models.ForeignKey(User, null=True, blank=True)


    def __unicode__(self):
        return self.image.name

    def size(self):
            return "%s x %s" % (self.width, …
Run Code Online (Sandbox Code Playgroud)

django create-view django-class-based-views detailview

5
推荐指数
1
解决办法
3916
查看次数