错误 老实说,我根本不了解如何解决。
我想我需要抽出矮人,但是怎么办?
class CreateVote(CreateView):
model = Vote
template_name = 'art_detail.html'
fields = ()
def get_initial(self):
initial = super().get_initial()
initial['art_id'] = self.kwargs['slug']
initial['author_id'] = self.request.user
return initial
def form_valid(self, form):
model = form.save(commit=False)
model.save()
return HttpResponseRedirect(self.get_success_url())
def get_success_url(self):
return reverse('art_detail')
Traceback:
return self.form_valid(form) ...
▼ Local vars
Variable Value
args ()
form < VoteForm bound=True, valid=True, fields=()>
kwargs {'slug': 'rrcom'}
request <WSGIRequest: POST '/poll/arts/rrcom/vote/'>
self <coll.views.CreateVote object at 0x0000000004709E48>
我指望您的支持,我还是新来的