mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
Add optional thumbnail model field.
This commit is contained in:
parent
cda1d0fd5e
commit
1ac5ae0a09
4 changed files with 10 additions and 3 deletions
|
|
@ -81,7 +81,7 @@ class CategoryAdmin(TreeEditor, admin.ModelAdmin):
|
|||
prepopulated_fields = {'slug': ('name',)}
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'fields': ('parent', 'name')
|
||||
'fields': ('parent', 'name', 'thumbnail')
|
||||
}),
|
||||
('Meta Data', {
|
||||
'fields': ('alternate_title', 'description', 'meta_keywords', 'meta_extra'),
|
||||
|
|
@ -117,4 +117,4 @@ for model,modeladmin in admin.site._registry.items():
|
|||
'fieldsets': fieldsets + (('Categories',{
|
||||
'fields': fields
|
||||
}),)
|
||||
}))
|
||||
}))
|
||||
|
|
|
|||
3
categories/migration/add_thumbnail.sql
Normal file
3
categories/migration/add_thumbnail.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
BEGIN;
|
||||
ALTER TABLE "categories_category" ADD COLUMN "thumbnail" varchar(100);
|
||||
COMMIT;
|
||||
|
|
@ -9,7 +9,7 @@ from django.utils.translation import ugettext as _
|
|||
|
||||
from mptt.models import MPTTModel
|
||||
|
||||
from settings import RELATION_MODELS, RELATIONS
|
||||
from settings import RELATION_MODELS, RELATIONS, THUMBNAIL_UPLOAD_PATH
|
||||
|
||||
class Category(MPTTModel):
|
||||
parent = models.ForeignKey('self',
|
||||
|
|
@ -19,6 +19,7 @@ class Category(MPTTModel):
|
|||
help_text="Leave this blank for an Category Tree",
|
||||
verbose_name='Parent')
|
||||
name = models.CharField(max_length=100)
|
||||
thumbnail = models.ImageField(upload_to=THUMBNAIL_UPLOAD_PATH, null=True, blank=True)
|
||||
order = models.IntegerField(blank=True, null=True)
|
||||
slug = models.SlugField()
|
||||
alternate_title = models.CharField(
|
||||
|
|
|
|||
|
|
@ -8,3 +8,6 @@ from django.db.models import Q
|
|||
DEFAULT_RELATION_MODELS = []
|
||||
RELATION_MODELS = getattr(settings, 'CATEGORIES_RELATION_MODELS', DEFAULT_RELATION_MODELS) or []
|
||||
RELATIONS = [Q(app_label=al, model=m) for al, m in [x.split('.') for x in RELATION_MODELS]]
|
||||
|
||||
# For assigning a thumbnail to a category
|
||||
THUMBNAIL_UPLOAD_PATH = getattr(settings, 'CATEGORIES_THUMBNAIL_UPLOAD_PATH', 'uploads/categories/thumbnails')
|
||||
|
|
|
|||
Loading…
Reference in a new issue