Skip to content

Commit

Permalink
Modelos creados y registrados en la Admin
Browse files Browse the repository at this point in the history
  • Loading branch information
jelukas committed Jul 21, 2012
1 parent af14e9d commit 5943791
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 32 deletions.
82 changes: 66 additions & 16 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions gestion/admin.py
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)
25 changes: 25 additions & 0 deletions gestion/models.py
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
16 changes: 0 additions & 16 deletions gestion/tests.py

This file was deleted.

Binary file added libreria.db
Binary file not shown.

0 comments on commit 5943791

Please sign in to comment.