0.7.65
profile change photo
This commit is contained in:
@@ -75,6 +75,8 @@ def change_avatar_confirm_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
file_data = json.loads(data[0])
|
file_data = json.loads(data[0])
|
||||||
head, content = file_data['file'].split(',')
|
head, content = file_data['file'].split(',')
|
||||||
@@ -83,6 +85,11 @@ def change_avatar_confirm_ajax(request):
|
|||||||
request.user.user_profile.avatar.save(file_data['file_name'], file)
|
request.user.user_profile.avatar.save(file_data['file_name'], file)
|
||||||
request.user.user_profile.save(update_fields=['avatar'])
|
request.user.user_profile.save(update_fields=['avatar'])
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
msg = f'change_avatar_confirm_ajax Error = {str(e)}'
|
||||||
|
print(msg)
|
||||||
|
JsonResponse({'error': msg})
|
||||||
|
|
||||||
return JsonResponse({'url': request.user.user_profile.avatar.url})
|
return JsonResponse({'url': request.user.user_profile.avatar.url})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user