Commit 06c147ea authored by gijs's avatar gijs

Moving to django filer for all thumbnails

parent 626ab93b
......@@ -138,7 +138,7 @@ class EventTypeAdmin(admin.ModelAdmin):
class ImageAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('image',)
'fields': ('image', 'filerImage')
}),
('Dutch', {
'fields': ('title_nl', 'tagline_nl', 'credit_nl')
......
from django.core.management.base import BaseCommand, CommandError
import filer.fields.image
from filer.models import Image as FilerImage
from django.contrib.auth.models import User
from django.core.files import File
import os.path
from contour.models import Image as ContourImage
class Command(BaseCommand):
args = ''
help = 'Fill filerimage field with DjangoFiler Models'
def handle(self, *args, **options):
for contourImage in ContourImage.objects.all():
# try:
user = User.objects.get(username='osp')
filepath = str(contourImage.image.file)
filename = os.path.basename(filepath)
with open(filepath, "rb") as f:
print(contourImage.image, contourImage.image.file, filepath)
# file_obj = File(f, name=filename)
# filerImage = FilerImage.objects.create(
# owner=user,
# original_filename=filename,
# file=file_obj)
# # print(filerImage, filerImage.file)
# # filerImage.save()
# contourImage.filerImage = filerImage
# print(contourImage.save())
# except:
# pass
\ No newline at end of file
# Generated by Django 2.1.1 on 2019-03-22 14:12
from django.conf import settings
from django.db import migrations
import django.db.models.deletion
import filer.fields.image
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.FILER_IMAGE_MODEL),
('contour', '0047_auto_20190319_1116'),
]
operations = [
migrations.AddField(
model_name='image',
name='filerImage',
field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.FILER_IMAGE_MODEL),
),
]
......@@ -41,7 +41,7 @@ class Venue(models.Model):
class Image(models.Model):
published = models.BooleanField(default=False)
image = models.ImageField(upload_to="images")
img = FilerImageField
filerImage = FilerImageField(null=True, blank=True, on_delete=models.CASCADE)
title_nl = models.CharField(max_length=255)
tagline_nl = models.CharField(max_length=255, null=True, blank=True)
title_en = models.CharField(max_length=255, verbose_name="Title (English)", null=True, blank=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment