This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.

30 lines
1.1 KiB
Python
Raw Permalink Normal View History

2021-02-09 17:41:06 +02:00
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)
# 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
2021-02-09 17:41:06 +02:00
class Image(models.Model):
title = models.CharField(max_length=200)
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