Executando verificação de segurança...
0

O backend pode ser assim:

import uuid
from django.db import models
from django.contrib.auth.models import User
from ckeditor.fields import RichTextField

def image_path(instance,filename):
    ext = filename.split("/")[-1]
    filename = f"{uuid.uuid4()}.{ext}"
    return f"banners/{filename}"}
    
class Base(models.Model):
    create_at = models.DateTimeField(auto_now_add=True)
    edited_at = models.DateTimeField(auto_now=True)
    is_active = models.BooleanField(default=True)


class Posts(Base):
    #Ou utilizar ManyToMany
    #author = models.ManyToManyField(User)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=255)
    description = RichTextField()
    banner = models.ImageField(upload_to=image_path, blank=True, null=True)
   
   E dai vai , pode colocar várias coisas.

Carregando publicação patrocinada...