noteworthy images

This commit is contained in:
Sanj 2012-10-19 14:57:52 +05:30
parent aa6954ea67
commit 6b5fd58eca
2 changed files with 21 additions and 2 deletions

View File

@ -7,6 +7,11 @@ class ProjectImageInline(admin.TabularInline):
extra = 20
class NoteworthyImageInline(admin.TabularInline):
model = NoteworthyImage
extra = 3
class ProjectAdmin(admin.ModelAdmin):
class Media:
js = (
@ -28,7 +33,7 @@ class NoteworthyAdmin(admin.ModelAdmin):
'js/jquery-ui-1.8.16.custom.min.js',
'js/admin_list_reorder.js',
)
inlines = [NoteworthyImageInline]
list_display = ('__unicode__', 'position',)
list_editable = ('position',)
exclude = ('position',)

View File

@ -96,7 +96,7 @@ class Link(models.Model):
class Noteworthy(models.Model):
position = models.IntegerField(null=True)
image = models.ImageField(blank=True, upload_to='noteworthy_imgs/')
image = models.ImageField(blank=True, upload_to='noteworthy_imgs/', help_text="main image")
title = models.CharField(max_length=255)
description = models.TextField(blank=True)
url = models.URLField(blank=True)
@ -122,5 +122,19 @@ class Noteworthy(models.Model):
def __unicode__(self):
return self.title
class NoteworthyImage(models.Model):
noteworthy = models.ForeignKey(Noteworthy)
image = models.ImageField(upload_to='noteworthy_imgs/')
order = models.IntegerField(default=1)
name = models.CharField(max_length=128, blank=True)
def __unicode__(self):
return self.image.url
class Meta:
ordering = ['order', 'id']
# Create your models here.