def profile_view(request): # TODO: Combine all profiles on this page hackathon = Hackathon.objects.first() try: profile = request.user.profile except: raise Http404("No profile") form = ProfileForm(instance=profile) notifications = [] if request.method == "POST": form = ProfileForm(request.POST, instance=profile) if form.is_valid(): form.save() notifications.append("Saved") # form.send_emails(self.request) when editable context = { "tab_title": "Profile", "hackathon": hackathon, "forms": [("", form)], "more_notifications": notifications, "show_subs": True, "show_email": True, } if hasattr(request.user, "iquhack_profile"): context.update({ "switch_to_label": "Edit iQuHACK Profile", "switch_to": reverse("iquhack:profile") }) return render(request, "members/profile.html", context)
def profile(request): if request.method == 'POST': form = ProfileForm(request.POST, request.FILES, instance=request.user) if form.is_valid(): form.save() form = ProfileForm(instance=request.user) return render(request, 'members/profile.html', context={'form': form})