from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Category(models.Model):
    name=models.CharField(max_length=100, verbose_name='Nombre')
    description=models.CharField(max_length=255, verbose_name='Descripcion')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='Creado el')
    
    class Meta:
        verbose_name = 'Categoria'
        verbose_name_plural = 'categorias'
        
    def __str__(self):
        return self.name

class Article(models.Model):
    title = models.CharField(max_length=150, verbose_name='Titulo')
    content = models.TextField(verbose_name='Contenido')
    image = models.ImageField(default='null', verbose_name='Imagen', upload_to='articles')
    public=models.BooleanField(verbose_name='¿publicado?')
    user = models.ForeignKey(User, editable=False, verbose_name='Usuario', on_delete=models.CASCADE) #BORRA REGISTRO Y TODO LO REFERENTE
    categories = models.ManyToManyField(Category, verbose_name=" categories", blank=True,related_name="articles")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='Creado el')
    update_at = models.DateTimeField(auto_now=True, verbose_name='Editado el' ) 
    
    class Meta:
        verbose_name = 'Articulo'
        verbose_name_plural= 'Articulos'
        ordering = ['-created_at'] #de mas nuevo a amas viejos 
        
    def __str__(self):
        return self.title
    
67f68801096051e737232f384977d625ba3bf67c
<mask token>


class Category(models.Model):
    <mask token>
    <mask token>
    <mask token>


    class Meta:
        verbose_name = 'Categoria'
        verbose_name_plural = 'categorias'
    <mask token>


class Article(models.Model):
    title = models.CharField(max_length=150, verbose_name='Titulo')
    content = models.TextField(verbose_name='Contenido')
    image = models.ImageField(default='null', verbose_name='Imagen',
        upload_to='articles')
    public = models.BooleanField(verbose_name='¿publicado?')
    user = models.ForeignKey(User, editable=False, verbose_name='Usuario',
        on_delete=models.CASCADE)
    categories = models.ManyToManyField(Category, verbose_name=
        ' categories', blank=True, related_name='articles')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name=
        'Creado el')
    update_at = models.DateTimeField(auto_now=True, verbose_name='Editado el')


    class Meta:
        verbose_name = 'Articulo'
        verbose_name_plural = 'Articulos'
        ordering = ['-created_at']

    def __str__(self):
        return self.title

<mask token>


class Category(models.Model):
    <mask token>
    <mask token>
    <mask token>


    class Meta:
        verbose_name = 'Categoria'
        verbose_name_plural = 'categorias'

    def __str__(self):
        return self.name


class Article(models.Model):
    title = models.CharField(max_length=150, verbose_name='Titulo')
    content = models.TextField(verbose_name='Contenido')
    image = models.ImageField(default='null', verbose_name='Imagen',
        upload_to='articles')
    public = models.BooleanField(verbose_name='¿publicado?')
    user = models.ForeignKey(User, editable=False, verbose_name='Usuario',
        on_delete=models.CASCADE)
    categories = models.ManyToManyField(Category, verbose_name=
        ' categories', blank=True, related_name='articles')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name=
        'Creado el')
    update_at = models.DateTimeField(auto_now=True, verbose_name='Editado el')


    class Meta:
        verbose_name = 'Articulo'
        verbose_name_plural = 'Articulos'
        ordering = ['-created_at']

    def __str__(self):
        return self.title

<mask token>


class Category(models.Model):
    name = models.CharField(max_length=100, verbose_name='Nombre')
    description = models.CharField(max_length=255, verbose_name='Descripcion')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name=
        'Creado el')


    class Meta:
        verbose_name = 'Categoria'
        verbose_name_plural = 'categorias'

    def __str__(self):
        return self.name


class Article(models.Model):
    title = models.CharField(max_length=150, verbose_name='Titulo')
    content = models.TextField(verbose_name='Contenido')
    image = models.ImageField(default='null', verbose_name='Imagen',
        upload_to='articles')
    public = models.BooleanField(verbose_name='¿publicado?')
    user = models.ForeignKey(User, editable=False, verbose_name='Usuario',
        on_delete=models.CASCADE)
    categories = models.ManyToManyField(Category, verbose_name=
        ' categories', blank=True, related_name='articles')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name=
        'Creado el')
    update_at = models.DateTimeField(auto_now=True, verbose_name='Editado el')


    class Meta:
        verbose_name = 'Articulo'
        verbose_name_plural = 'Articulos'
        ordering = ['-created_at']

    def __str__(self):
        return self.title

from django.db import models
from django.contrib.auth.models import User


class Category(models.Model):
    name = models.CharField(max_length=100, verbose_name='Nombre')
    description = models.CharField(max_length=255, verbose_name='Descripcion')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name=
        'Creado el')


    class Meta:
        verbose_name = 'Categoria'
        verbose_name_plural = 'categorias'

    def __str__(self):
        return self.name


class Article(models.Model):
    title = models.CharField(max_length=150, verbose_name='Titulo')
    content = models.TextField(verbose_name='Contenido')
    image = models.ImageField(default='null', verbose_name='Imagen',
        upload_to='articles')
    public = models.BooleanField(verbose_name='¿publicado?')
    user = models.ForeignKey(User, editable=False, verbose_name='Usuario',
        on_delete=models.CASCADE)
    categories = models.ManyToManyField(Category, verbose_name=
        ' categories', blank=True, related_name='articles')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name=
        'Creado el')
    update_at = models.DateTimeField(auto_now=True, verbose_name='Editado el')


    class Meta:
        verbose_name = 'Articulo'
        verbose_name_plural = 'Articulos'
        ordering = ['-created_at']

    def __str__(self):
        return self.title

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Category(models.Model):
    name=models.CharField(max_length=100, verbose_name='Nombre')
    description=models.CharField(max_length=255, verbose_name='Descripcion')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='Creado el')
    
    class Meta:
        verbose_name = 'Categoria'
        verbose_name_plural = 'categorias'
        
    def __str__(self):
        return self.name

class Article(models.Model):
    title = models.CharField(max_length=150, verbose_name='Titulo')
    content = models.TextField(verbose_name='Contenido')
    image = models.ImageField(default='null', verbose_name='Imagen', upload_to='articles')
    public=models.BooleanField(verbose_name='¿publicado?')
    user = models.ForeignKey(User, editable=False, verbose_name='Usuario', on_delete=models.CASCADE) #BORRA REGISTRO Y TODO LO REFERENTE
    categories = models.ManyToManyField(Category, verbose_name=" categories", blank=True,related_name="articles")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='Creado el')
    update_at = models.DateTimeField(auto_now=True, verbose_name='Editado el' ) 
    
    class Meta:
        verbose_name = 'Articulo'
        verbose_name_plural= 'Articulos'
        ordering = ['-created_at'] #de mas nuevo a amas viejos 
        
    def __str__(self):
        return self.title
    