aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/profile/utils.py
blob: 27067d51cdae078275a3bd6cadddfb2ea9a6353a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#-*- coding: utf-8 -*-

import random

from django.conf import settings


def avatar_by_user(user):
	"""
		生成头像
	"""
	from django.core.files.images import ImageFile

	_avatar_path = "%s/avatars/%s.png" % (settings.MEDIA_ROOT, random.randint(1,22))

	_avatar = ImageFile(open(_avatar_path))
	user.profile.avatar = _avatar
	user.profile.save()
	return user.profile