View difference between Paste ID: aTq8BWgG and 6Sfc8SYw
SHOW: | | - or go back to the newest paste.
1
#models
2
class Noticia(models.Model):
3
    publicado = models.ForeignKey(Perfil, editable = False)
4
    titulo    = models.CharField('Título', max_length = 250, blank = False, null =False)
5
    cuerpo    = models.TextField('Noticia', blank = False, null =False)
6
    fecha     = models.DateField('Fecha de publicación', default = datetime.date.today(), editable = False)
7
    foto      = models.CharField('Thumb', max_length = 250, blank = True, null = True)
8
    fuente    = models.CharField('Fuente', max_length = 20, blank = False, null =False)
9
10
    class Meta:
11
        verbose_name = 'Noticia'
12
        verbose_name_plural = 'Noticias'
13
14
    def __unicode__(self):
15
        return u'%s' % (self.titulo)
16
17
    def get_titulo(self):
18
        return u'%s' % self.titulo.replace(' ', '_')
19
20
    def vista_previa(self):
21
        if self.foto:
22
            return '<img src="%s" alt="thumb" heigth="50px" width="50px"/>' % self.foto
23-
    vista_previa.allow_tags = True
23+
24
    vista_previa.allow_tags = True
25
26
#admin
27
class NoticiaAdmin(admin.ModelAdmin):
28
    list_display      = ('titulo','publicado','fecha','fuente','vista_previa',)
29
    search_fields     = ['titulo','fuente']
30
    list_per_page     = 25
31
    list_max_show_all = 30
32
33
    class Media:
34
        js = ('grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js',
35
                'filebrowser/js/FB_TinyMCE.js',
36
                'filebrowser/js/TinyMCEAdmin.js',)