I want to make've limited the number of users on the upload file. For example: Every day, users are limited to 1 image file.
Views
class Upload(views.LoginRequiredMixin, generic.CreateView):
model = Posts
form_class = UploadForm
template_name = 'icerik_yukle.html'
def form_valid(self, form):
self.object = form.save(commit=False)
self.object.author= self.request.user
self.object.save()
return super(Upload, self).form_valid(form)
Models
class Gonderi(models.Model):
author= models.ForeignKey(User, related_name="gonderi")
slug = models.SlugField(unique=True, max_length=10, default=id_olustur)
image = models.FileField(upload_to=yukleme_adresi, blank=True)
subject= models.CharField(max_length=50, blank=True)
descrip = models.TextField(max_length=250, blank=True)
category= models.ForeignKey(Kategori, verbose_name="Kategori")
tags = TaggableManager()
created= models.DateTimeField(auto_now_add=True)
updated= models.DateTimeField(auto_now=True)
is_public = models.BooleanField(verbose_name='Göster', default=True)