we did it bois, we enter in the user id for each one
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user