-
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.
Modelos creados y registrados en la Admin
- Loading branch information
Showing
5 changed files
with
100 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib import admin | ||
|
||
from gestion.models import Libro | ||
from gestion.models import Categoria | ||
from gestion.models import Autor | ||
|
||
admin.site.register(Libro) | ||
admin.site.register(Categoria) | ||
admin.site.register(Autor) |
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,28 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class Libro(models.Model): | ||
titulo = models.CharField(max_length=250) | ||
descripcion = models.TextField() | ||
fecha_publicacion = models.DateField(blank=True) | ||
categoria = models.ForeignKey('Categoria', related_name='libros') | ||
|
||
def __str__(self): | ||
return self.titulo | ||
|
||
|
||
class Autor(models.Model): | ||
nombre = models.CharField(max_length=250) | ||
apellidos = models.CharField(max_length=250) | ||
libros = models.ManyToManyField('Libro', related_name='autores') | ||
|
||
def __str__(self): | ||
return self.nombre + " " + self.apellidos | ||
|
||
|
||
class Categoria(models.Model): | ||
nombre = models.CharField(max_length=250) | ||
descripcion = models.TextField() | ||
|
||
def __str__(self): | ||
return self.nombre |
This file was deleted.
Oops, something went wrong.
Binary file not shown.