-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creados Modelos Y Campos Para La App Blog
Creado un campo blog de tipo OneToOneField dentro del modelo Culture, Creados Los Modelos Blog, Post, y Category; Redefinicion del metodo __str__ dentro del modelo Dict, Y Creada una senal para crear un blog automaticamente durante el pre_save del modelo Culture.
- Loading branch information
ChekeGT
committed
Sep 20, 2018
1 parent
c0fd568
commit bc4c1bc
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,47 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
|
||
class Category(models.Model): | ||
name = models.CharField(max_length=200, verbose_name='Nombre') | ||
created = models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creacion') | ||
updated = models.DateTimeField(auto_now=True, verbose_name='Fecha de edicion') | ||
|
||
class Meta: | ||
ordering = ['name'] | ||
verbose_name = 'Categoria' | ||
verbose_name_plural = 'Categorias' | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
class Post(models.Model): | ||
title = models.CharField(max_length=250, verbose_name='Titulo') | ||
image = models.ImageField(upload_to='post_images/',verbose_name='Imagen') | ||
content = models.TextField(verbose_name='Contenido') | ||
categories = models.ManyToManyField(Category) | ||
created = models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creacion') | ||
updated = models.DateTimeField(auto_now=True, verbose_name='Fecha de edicion') | ||
|
||
class Meta: | ||
ordering = ['title'] | ||
verbose_name = 'Publicacion' | ||
verbose_name_plural = 'Publicaciones' | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
|
||
class Blog(models.Model): | ||
posts = models.ManyToManyField(Post) | ||
created = models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creacion') | ||
updated = models.DateTimeField(auto_now=True, verbose_name='Fecha de edicion') | ||
|
||
class Meta: | ||
ordering = ['updated'] | ||
verbose_name_plural = 'Blogs' | ||
verbose_name = 'Blog' | ||
|
||
def __str__(self): | ||
return 'Blog Numero: {}'.format(self.pk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters