Exemple #1
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect('/app/profile')
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'app/edit_profile.html', args)
Exemple #2
0
 def post(self, request, *args, **kwargs):
     user = User.objects.filter(username=self.kwargs['username']).first()
     profile = Profile.objects.filter(user=user).first()
     user_form = EditUserForm(request.POST, instance=user)
     profile_form = EditProfileForm(request.POST, instance=profile)
     if user_form.is_valid() and profile_form.is_valid():
         user_form = user_form.save()
         custom_form = profile_form.save(False)
         custom_form.user = user_form
         custom_form.save()
         return redirect('user', username=user.username)
     return render(request, self.template_name, args)
Exemple #3
0
def edit_profile(request):

	context = {}

	try:
		user = CustomUser.objects.get(pk=request.user.pk)
	except Exception, e:
		raise Http404('404')

	form = EditProfileForm(request.POST or None, instance=user)

	context['form'] = form

	if form.is_valid():
		form.save()
		return redirect('/profile/')
	else:
		print form.errors

	return render(request, 'edit_profile.html', context)

@staff_member_required
def delete_album(request, pk):

	album = Album.objects.get(pk=pk)

	album.delete()

	artist = album.artist