我想阻止用户在发布日期后 24 小时后更新帖子
class Post(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
title= models.CharField(max_length=50)
post = models.TextField(max_length=400)
date = models.DateTimeField(auto_now_add=True)
edit = models.DateTimeField(auto_now=True)
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = '__all__'
class PostUpdateView(LoginRequiredMixin,SuccessMessageMixin,UpdateView):
model = Post
form_class = PostForm
success_message = "updated successfully"
template_name = 'store/create.html'
success_url = reverse_lazy('lists')
def form_valid(self,form):
return super().form_valid(form)
我想让用户只能在发布日期的 24 小时之前更新帖子 谢谢
一只甜甜圈
相关分类