这是我的models.py:
select count(address_column like '%mumbai%' or null)*100/count(*) as percentage from your_table;
和forms.py:
class Segment(models.Model):
email_segment_name = models.CharField(max_length=200)
email_segment_status = models.BooleanField()
user = models.ForeignKey(User,on_delete=models.SET_NULL,blank=True,null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.email_segment_name
和观点:
class SegmentForm(forms.ModelForm):
class Meta:
model = Segment
fields = ['email_segment_name']
labels = {
'email_server_name':('Server Name'),
}
segment_update_form.html:
@method_decorator(login_required, name='dispatch')
class SegmentUpdate(UpdateView):
model = Segment
form_class = SegmentForm
template_name_suffix = '_update_form'
success_url = '/emails/segment'
FormView和DeleteView工作正常,但是当我更新表单时,它会响应200 OK并且页面是空白的,有什么想法吗?
答案 0 :(得分:0)
变化:
method='post'
为:
method='get'
在segment_update_form.html 中