def myprofile(request): if request.POST: form = ProfileForm(request.POST, request.FILES) if form.is_valid(): profile_current = form.save(commit=False) profile_current.user = request.user profile_current.save() else: form = ProfileForm() user = request.user if Profile.objects.filter(user=user): profile = Profile.objects.get(user=user) else: profile = None object_list = Article.objects.filter(user=user) topic_list = list(set([x.topic for x in object_list.all()])) print(topic_list) return render( request, "myprofile.html", { "object": profile, "topic_list": topic_list, "object_list": object_list, "form": form })