我在以下设置中收到“DoesNotExist”错误 - 我已经尝试调试了一段时间,但无法弄清楚。
class Video(models.Model):
name = models.CharField(max_length=100)
type = models.CharField(max_length=100)
owner = models.ForeignKey(User, related_name='videos')
...
#Related m2m fields
....
class VideoForm(modelForm):
class Meta:
model = Video
fields = ('name', 'type')
class VideoCreate(CreateView):
template_name = 'video_form.html'
form_class = VideoForm
model = Video
当我这样做并发布“名称”和“类型”的数据时 - 我收到“DoesNotExist”错误。它似乎与 UpdateView 一起工作正常 - 或者当传递一个“实例”来初始化表单时。
这是引发错误的确切位置: /usr/lib/pymodules/python2.7/django/db/models/fields/related.py in get,第 301 行
有谁知道可能会发生什么?
谢谢