def profile(request): if request.method == 'POST': u_form = UserUpdateForm(request.POST, instance=request.user) p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if u_form.is_valid() and p_form.is_valid(): u_form.save() p_form.save() messages.success(request, f'Your account has been updated!') return redirect('profile') else: u_form = UserUpdateForm(instance=request.user) p_form = ProfileUpdateForm(instance=request.user.profile) context = {'u_form': u_form, 'p_form': p_form} return render(request, 'users/profile.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been successfully updated') return HttpResponseRedirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) current_user = request.user shopcart = ShopCart.objects.filter(user_id=current_user.id) shipping = 0 for rs in shopcart: shipping = float(2000) subtotal = 0 for rs in shopcart: subtotal += rs.product.price * rs.quantity total = 0 for rs in shopcart: total += rs.product.price * rs.quantity added = 0 for rs in shopcart: added += rs.quantity context = { 'category': category, 'total': total, 'added': added, 'user_form': user_form, 'profile_form': profile_form } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() # # messages.warning(request, 'your account updated!') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm (instance=request.user) profile_form = ProfileUpdateForm(instance= request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, } return render (request, 'user_update.html',context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been updated!') return HttpResponseRedirect('/user') category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) # request.user is user_data # "instance=request.user.user_profile" comes from "user_profile" model -> OneToOneField Relation profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been updated!') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) # "user_profile" model -> OneToOneField Relation with user context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) # request.user is user data profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Profiliniz başarı ile güncellendi !') return redirect('/user') else: menu = Menu.objects.all() current_user = request.user # Access user session information user_form = UserUpdateForm(instance=request.user) # userla ilişki kursun diyorum profile_form = ProfileUpdateForm(instance=request.user.userprofile) # "userprofile" model -> OneToOneField relatinon with user =>yani user tablosundaki userprofileı onetoone ilişkisine göre getir diyorum context = { 'menu': menu, 'user_form': user_form, 'profile_form': profile_form, } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'HEsabınız güncellendi') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form } return render(request, 'user_update.html', context)
def profile(request): if request.method == 'POST': pform = ProfileForm(request.POST, request.FILES, instance=request.user.profile) uform = UserUpdateForm(request.POST, instance=request.user) if pform.is_valid() and uform.is_valid(): pform.save() uform.save() return HttpResponseRedirect(reverse('profile')) # return HttpResponse(request.FILES) else: pform = ProfileForm(instance=request.user.profile) uform = UserUpdateForm(instance=request.user) return render(request, 'user/profile.html', { 'pform': pform, 'uform': uform })
def home(request): if request.method == 'POST': u_form = UserUpdateForm(request.POST, instance=request.user) p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if u_form.is_valid() and p_form.is_valid(): u_form.save() p_form.save() messages.success(request, f'Your account has been updated!') return redirect('base:base-home') else: u_form = UserUpdateForm(instance=request.user) p_form = ProfileUpdateForm(instance=request.user.profile) context = { 'u_form': u_form, 'p_form': p_form, 'posts': Post.objects.all(), 'productpics': ProductPic.objects.all() } return render(request, 'base/home.html', context)
def UpdateProfile(request): user_instance = request.user profile_instance = user_instance.profile if request.method == "POST": profile_form = ProfileForm(request.POST, instance=profile_instance) user_form = UserUpdateForm(request.POST, instance=user_instance) if profile_form.is_valid() and user_form.is_valid(): profile_form.save() # user = user_form.save(commit=False) user_form.save() else: profile_form = ProfileForm(instance=profile_instance) user_form = UserUpdateForm(instance=user_instance) return render(request, "account/profile.html", { 'user_form': user_form, 'profile_form': profile_form })
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) # request.user kullanıcı verisidir # "instance = request.user.userprofile", "userprofile" modelinden gelir -> OneToOneField ilişkisi profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) # instance ile bağlıyoruz if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been updated!') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_from = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_from.is_valid() and profile_form.is_valid(): user_from.save() profile_form.save() messages.success(request, "your profile update") return HttpResponseRedirect('/user') else: Category = catagory.objects.all() user_from = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': Category, 'user_from': user_from, 'profile_form': profile_form } return render(request, 'user_update.html', context)
def user_update(request): setting = Setting.objects.get(pk=1) if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) # user ile ilişki kur profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Bilgileriniz Güncellendi') return redirect('/user') else: category = Category.objects.all() current_user = request.user user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm( instance=request.user.userprofile) # user ile userprofile onetoone ilişkisi kuruyor context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form,'setting': setting } return render(request, 'user_update.html', context)
def profile(request): username = request.user.username if request.method == 'POST': user_update_form = UserUpdateForm(request.POST, instance=request.user) profile_update_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if user_update_form.is_valid() and profile_update_form.is_valid(): user_update_form.save() profile_update_form.save() messages.success(request, 'Your profile has been updated!') return redirect('profile') else: user_update_form = UserUpdateForm(instance=request.user) profile_update_form = ProfileUpdateForm(instance=request.user.profile) context = { 'user_update_form': user_update_form, 'profile_update_form': profile_update_form, 'username': username } return render(request, 'user/profile.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Profiliniz başarı ile güncellenmiştir.') return redirect('/user') else: category = Category.objects.all() current_user = request.user setting = Setting.objects.get(pk=1) user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'setting':setting } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) # request.user is user data profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Profilin başarıyla güncellendi!') return HttpResponseRedirect('/user') else: category = Category.objects.all() setting = Setting.objects.get(pk=1) user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm( instance=request.user.userprofile) # "userprofile" model -> OneToOneField relatinon with user context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'setting': setting, } return render(request, 'user_update.html', context)
def update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Hesabın başarıyla güncellendi.') return redirect('/user') else: setting = Settings.objects.get(pk=1) category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'setting': setting, 'category': category, 'user_form': user_form, 'profile_form': profile_form, } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Porifliniz güncellendi') return redirect('/user') else: user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) user = request.user current_user = UserProfile.objects.get(user_id=user.id) context = { 'user_form': user_form, 'profile_form': profile_form, 'profile': current_user, } return render(request, 'user_update.html', context)
def user_update(request): setting = Setting.objects.get(pk=1) last_posts = Post.objects.filter(status=True).order_by('-id')[:4] if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Profiliniz başarıyla güncellendi.') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) #model user data profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = {'setting': setting, 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'last_posts': last_posts, } return render(request, 'user_update.html', context)
def profile(request): rank = get_rank(request.user.userprofile) if request.method == 'POST': profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) user_form = UserUpdateForm(request.POST, instance=request.user) if profile_form.is_valid() and user_form.is_valid(): mess.success(request, 'Successfully changed your Profile') profile_form.save() user_form.save() return HttpResponseRedirect(reverse('game:profile')) else: profile_form = ProfileUpdateForm(instance=request.user.userprofile) user_form = UserUpdateForm(instance=request.user) context = { 'rank': rank, 'user_form': user_form, 'profile_form': profile_form, } return (render(request, 'game/profile.html', context))
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been updated!') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm( instance=request.user.userprofile ) #güncelleme old için diğer formdan bilgileri alıyor context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form } return render(request, 'user_update.html', context)
def userprofileupdate(request): category = Category.objects.all() setting = Setting.objects.get(pk=1) if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Successfully Profile Updated') return HttpResponseRedirect('/user/userprofile/') else: user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'setting': setting, 'category': category, 'user_form': user_form, 'profile_form': profile_form, } return render(request, 'userprofileupdate.html', context)
def user_update(request): menu = Menu.objects.all() if request.method == "POST": user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your profile has been updated') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'menu': menu } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Profiliniz başarıyla güncellendi!') return redirect('/user') else: category = Category.objects.all() current_user = request.user profile = UserProfile.objects.get(user_id=current_user.id) user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) context = { 'category': category, 'user_form': user_form, 'profile': profile, 'profile_form': profile_form } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been updated!') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) shop_cart = ShopCart.objects.filter(user_id=current_user.id) total = 0 for rs in shop_cart: total += rs.product.price * rs.quantity context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'total': total } return render(request, 'user_update.html', context)
def user_update(request): setting = Setting.objects.get(pk=1) if request.method == 'POST': user_form = UserUpdateForm(request.POST, instance=request.user) profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Your account has been updated!') return redirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm(instance=request.user.userprofile) if request.user.is_authenticated: current_user = request.user profile = UserProfile.objects.get(user_id=current_user.id) context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'profile': profile, 'setting': setting, } return render(request, 'user_update.html', context) else: context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form, 'setting': setting, } return render(request, 'user_update.html', context)
def user_update(request): if request.method == 'POST': user_form = UserUpdateForm( request.POST, instance=request.user) # request.user is user data profile_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.userprofile) if user_form.is_valid() and profile_form.is_valid(): user_form.save() profile_form.save() messages.success(request, 'Ваш профиль успешно обновлен!') return HttpResponseRedirect('/user') else: category = Category.objects.all() user_form = UserUpdateForm(instance=request.user) profile_form = ProfileUpdateForm( instance=request.user.userprofile ) # "userprofile" model -> OneToOneField relatinon with user context = { 'category': category, 'user_form': user_form, 'profile_form': profile_form } return render(request, 'user_update.html', context)