Answer the question
In order to leave comments, you need to log in
Edit user profile?
Guys, I'm trying to make a page for editing my data, for users.
I do this way: I
created a template, a view.
in the view.py file, I take the form for filling out the profile, which is used during registration, into the variable, and into the variable I enter the data from the model that the current user has.
---view.py
def edit_profile_printing(request):
editForm = PrintshopProfileForm()
profilData = PrintShop.objects.filter(user__email=request.user)
if profilData:
for person in profilData:
editForm.country = person.country
else:
print("NOT")
return render(request, 'profile/profile_printing.html', {'editForm':editForm})
Answer the question
In order to leave comments, you need to log in
from django.shortcuts import get_object_or_404
def edit_profile_printing(request):
profil_data = get_object_or_404(PrintShop, user=request.user)
edit_form = PrintshopProfileForm(instance=profile_data)
return render(request, 'profile/profile_printing.html', {'editForm':edit_form})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question