add in stdimage to scale the images
This commit is contained in:
parent
a6ba1f984b
commit
0a2ad28b7c
|
@ -28,6 +28,7 @@ DJANGO_APPS = (
|
||||||
'django.contrib.sites',
|
'django.contrib.sites',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'stdimage',
|
||||||
|
|
||||||
# Useful template tags:
|
# Useful template tags:
|
||||||
# 'django.contrib.humanize',
|
# 'django.contrib.humanize',
|
||||||
|
|
|
@ -35,12 +35,26 @@ EMAIL_HOST = env("EMAIL_HOST", default='mailhog')
|
||||||
|
|
||||||
# CACHING
|
# CACHING
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
REDIS_LOCATION = '{0}/{1}'.format(env('REDIS_URL', default='redis://redis:6379'), 0)
|
||||||
|
# Heroku URL does not pass the DB number, so we parse it in
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
'BACKEND': 'django_redis.cache.RedisCache',
|
||||||
'LOCATION': ''
|
'LOCATION': REDIS_LOCATION,
|
||||||
|
'OPTIONS': {
|
||||||
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||||
|
'IGNORE_EXCEPTIONS': True, # mimics memcache behavior.
|
||||||
|
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# CACHES = {
|
||||||
|
# 'default': {
|
||||||
|
# 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
|
# 'LOCATION': ''
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
# django-debug-toolbar
|
# django-debug-toolbar
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
4
dev.yml
4
dev.yml
|
@ -26,7 +26,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8180:8000"
|
||||||
links:
|
links:
|
||||||
- postgres
|
- postgres
|
||||||
- mailhog
|
- mailhog
|
||||||
|
@ -36,3 +36,5 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "8125:8025"
|
- "8125:8025"
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<h2>Profile</h2>
|
<h2>Profile</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<img src="{{ MEDIA_URL }}{{ user.image }}" alt="Profile image"/>
|
<img src="{{ user.image.profile.url }}" alt="Profile image"/>
|
||||||
|
|
||||||
<p>{{ user.username }}</p>
|
<p>{{ user.username }}</p>
|
||||||
<p>{{ user.name }}</p>
|
<p>{{ user.name }}</p>
|
||||||
|
|
|
@ -7,12 +7,20 @@ from django.core.urlresolvers import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from stdimage.models import StdImageField
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class User(AbstractUser):
|
class User(AbstractUser):
|
||||||
name = models.CharField(_('Name of User'), blank=True, max_length=255)
|
name = models.CharField(_('Name of User'), blank=True, max_length=255)
|
||||||
image = models.ImageField(upload_to='avatars/', blank=True, null=True)
|
image = StdImageField(
|
||||||
|
upload_to='avatars/',
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
variations={
|
||||||
|
'profile': {
|
||||||
|
"width": 256,
|
||||||
|
"height": 256,
|
||||||
|
"crop": True}})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
|
@ -17,6 +17,7 @@ django-braces==1.10.0
|
||||||
django-crispy-forms==1.6.1
|
django-crispy-forms==1.6.1
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
|
django-stdimage
|
||||||
django-model-utils==2.6
|
django-model-utils==2.6
|
||||||
|
|
||||||
# Images
|
# Images
|
||||||
|
|
Loading…
Reference in New Issue