views.py
class Post(CreateView):
fields = ('title', 'desc')
model = models.Post
def form_valid(self, form):
self.object = form.save(commit=False)
self.object.desc = self.object.id <----
self.object.save()
return super(ModelFormMixin, self).form_valid(form)
如何在分配前从帖子中获取对象ID?我尝试使用self.object.id
但返回none