models.py:
class UserProfile(models.Model):
photo = models.ImageField(upload_to = get_upload_file_name,
storage = OverwriteStorage(),
default = os.path.join(settings.STATIC_ROOT,'images','generic_profile_photo.jpg'),
height_field = 'photo_height',
width_field = 'photo_width')
photo_height = models.PositiveIntegerField(blank = True, default = 0)
photo_width = models.PositiveIntegerField(blank = True, default = 0)
views.py:
def EditProfile(request):
register_generator()
source_file = UserProfile.objects.get(user = request.user).photo
args = {}
args.update(csrf(request))
args.update({'source_file' : source_file})
somewhere in my template:
{% generateimage 'user_profile:thumbnail' source=source_file %}
I receive an error: UserProfile matching query does not exist.
at this line:
source_file = UserProfile.objects.get(user = request.user).photo
The problem is that the default atribute of ImageField is not working. Thus, the object is not created inside my model. How to use this atribute properly? If I ommit this atribute, the object is created with no errors. Do I need to pass the absolute or relative path? I am using django-imagekit to resize the image before dispalying it: http://django-imagekit.readthedocs.org/en/latest/