we did it bois, we enter in the user id for each one

This commit is contained in:
Yamozha
2021-02-18 00:31:54 +02:00
parent 322047b51b
commit a62ccb389d
35 changed files with 48 additions and 12 deletions

View File

@ -1,5 +1,6 @@
from django.db import models
from .validators import videoValidate, imageValidate
from django.contrib.auth.models import User
# def user_directory._path(instance, filename):
# print(request.user.id)
@ -10,18 +11,19 @@ from .validators import videoValidate, imageValidate
class Image(models.Model):
title = models.CharField(max_length=200)
image = models.ImageField(upload_to=f"images/{upload_to}",validators=[imageValidate])
image = models.ImageField(upload_to=f"images/",validators=[imageValidate])
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
def __str__(self):
return self.title
class Videos(models.Model):
title = models.CharField(max_length=100)
video = models.FileField(upload_to=f'videos/', validators=[videoValidate])
class Meta:
verbose_name = 'video'
verbose_name_plural = 'videos'
def __str__(self):
return self.title