28 lines
987 B
Python
28 lines
987 B
Python
from django.db import models
|
|
from .validators import videoValidate, imageValidate
|
|
|
|
# def user_directory._path(instance, filename):
|
|
# print(request.user.id)
|
|
# return 'user_{0}/{1}'.format(instance.user.id, filename)
|
|
# Ok i got hella angry, so pleaSE fix this bullshit
|
|
# I want to be able to store each and every user's files in a separate folder, based on their id
|
|
# I CANT GET A FUCKING LOGGED IN USER ID FROM THE MODELS THINGY IM FUCKING PISSED
|
|
|
|
class Image(models.Model):
|
|
title = models.CharField(max_length=200)
|
|
image = models.ImageField(upload_to=f"images/{upload_to}",validators=[imageValidate])
|
|
|
|
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
|