Commit 7f986bdc authored by Ciella Francisco's avatar Ciella Francisco 😵

Enabled conversion of uploaded image extension to webp for optimization in...

Enabled conversion of uploaded image extension to webp for optimization in loading the images on the web app
parent 63cb44d3
from django.db import models
from django_resized import ResizedImageField
from django.utils import timezone
from django.urls import reverse
from datetime import timedelta
from accounts import models as accounts
# from datetime import timedelta
class Event(models.Model):
event_name = models.CharField(default='', max_length=150)
event_datetime_start = models.DateTimeField(default=timezone.now, null=False)
event_datetime_end = models.DateTimeField(default=None, null=True)
event_organizer = models.ForeignKey(accounts.CustomUser, on_delete=models.CASCADE, related_name='events_organized')
# finalize arguments
event_header = models.ImageField(upload_to='headers/', height_field=None, width_field=None, max_length=100, blank=True)
event_header = ResizedImageField(size=[815, 315], crop=['middle', 'center'], quality=75, force_format='WebP', upload_to=rename_image('headers/'))
last_time_bumped = models.DateTimeField()
def __str__(self):
......
......@@ -131,6 +131,13 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DJANGORESIZED_DEFAULT_SIZE = [815, 315]
DJANGORESIZED_DEFAULT_QUALITY = 75
DJANGORESIZED_DEFAULT_KEEP_META = True
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'WebP'
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'WebP': ".webp"}
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True
LOGIN_REDIRECT_URL = "index"
LOGOUT_REDIRECT_URL = "index"
AUTH_USER_MODEL = "accounts.CustomUser"
......
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