Creacion Blog
This commit is contained in:
parent
44aaab57ea
commit
b284f796f8
@ -39,6 +39,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
'ProyectoWebApp',
|
||||
'servicios',
|
||||
'blog',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
0
ProyectoWeb/blog/__init__.py
Normal file
0
ProyectoWeb/blog/__init__.py
Normal file
16
ProyectoWeb/blog/admin.py
Normal file
16
ProyectoWeb/blog/admin.py
Normal file
@ -0,0 +1,16 @@
|
||||
from django.contrib import admin
|
||||
from .models import Categoria, Entrada
|
||||
|
||||
# Register your models here.
|
||||
|
||||
class CategoriaAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ('created', 'updated')
|
||||
|
||||
|
||||
class EntradasAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ('created', 'updated')
|
||||
|
||||
|
||||
admin.site.register(Categoria, CategoriaAdmin)
|
||||
admin.site.register(Entrada, EntradasAdmin)
|
||||
|
5
ProyectoWeb/blog/apps.py
Normal file
5
ProyectoWeb/blog/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BlogConfig(AppConfig):
|
||||
name = 'blog'
|
47
ProyectoWeb/blog/migrations/0001_initial.py
Normal file
47
ProyectoWeb/blog/migrations/0001_initial.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Generated by Django 3.1.3 on 2020-11-21 05:08
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Categoria',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('nombre', models.CharField(max_length=50)),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'categoria',
|
||||
'verbose_name_plural': 'categorias',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Entrada',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('titulo', models.CharField(max_length=50)),
|
||||
('contenido', models.CharField(max_length=50)),
|
||||
('imagen', models.ImageField(blank=True, null=True, upload_to='blog')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now_add=True)),
|
||||
('autor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
('categorias', models.ManyToManyField(to='blog.Categoria')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'entrada',
|
||||
'verbose_name_plural': 'entradas',
|
||||
},
|
||||
),
|
||||
]
|
0
ProyectoWeb/blog/migrations/__init__.py
Normal file
0
ProyectoWeb/blog/migrations/__init__.py
Normal file
Binary file not shown.
BIN
ProyectoWeb/blog/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
ProyectoWeb/blog/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
37
ProyectoWeb/blog/models.py
Normal file
37
ProyectoWeb/blog/models.py
Normal file
@ -0,0 +1,37 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Categoria(models.Model):
|
||||
nombre = models.CharField( max_length = 50 )
|
||||
created = models.DateTimeField( auto_now_add = True)
|
||||
updated = models.DateTimeField( auto_now_add = True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'categoria'
|
||||
verbose_name_plural = 'categorias'
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.nombre
|
||||
|
||||
|
||||
class Entrada(models.Model):
|
||||
titulo = models.CharField( max_length = 50 )
|
||||
contenido = models.CharField( max_length = 50 )
|
||||
autor = models.ForeignKey( User, on_delete = models.CASCADE )
|
||||
categorias = models.ManyToManyField( Categoria )
|
||||
imagen = models.ImageField( upload_to='blog', null=True, blank=True )
|
||||
created = models.DateTimeField( auto_now_add = True)
|
||||
updated = models.DateTimeField( auto_now_add = True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'entrada'
|
||||
verbose_name_plural = 'entradas'
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.titulo
|
||||
|
||||
|
3
ProyectoWeb/blog/views.py
Normal file
3
ProyectoWeb/blog/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in New Issue
Block a user