We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Fix Bugs when profile is being viewed
### Description

The serialization is not correct when the registered user tries to view their own profile



This comes from the serialization part of our code-base which can be viewed [here](https://github.com/CiviWiki/OpenCiviWiki/blob/develop/project/threads/views.py#L181-L245)

```py
thread_wiki_data = {
        "thread_id": thread_id,
        "title": Thread_filter.title,
        "summary": Thread_filter.summary,
        "image": Thread_filter.image_url,
        "author": {
            "username": Thread_filter.author.user.username,
            "profile_image": Thread_filter.author.profile_image_url,
            "first_name": Thread_filter.author.first_name,
            "last_name": Thread_filter.author.last_name,
        },
        "contributors": [
            Profile.objects.chip_summarize(a)
            for a in Profile.objects.filter(
                pk__in=civis.distinct("author").values_list("author", flat=True)
            )
        ],
        "category": {
            "id": Thread_filter.category.id,
            "name": Thread_filter.category.name,
        },
        "categories": [{"id": c.id, "name": c.name} for c in Category.objects.all()],
        "created": Thread_filter.created_date_str,
        "num_civis": Thread_filter.num_civis,
        "num_views": Thread_filter.num_views,
        "user_votes": [
            {
                "civi_id": act.civi.id,
                "activity_type": act.activity_type,
                "c_type": act.civi.c_type,
            }
            for act in Activity.objects.filter(
                thread=Thread_filter.id, account=req_acct.id
            )
        ],
    }
```

### What should have happened?

The serialization should return user appropriately

### What browser(s) are you seeing the problem on?

Chrome, Firefox, Microsoft Edge, Safari

### Further details

![image](https://user-images.githubusercontent.com/67182544/138872174-8fadf9a9-bf2e-40fb-a9b8-7c630ba8a676.png)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `project/accounts/views.py`
Content:
```
1 """
2 Class based views.
3 
4 This module will include views for the accounts app.
5 """
6 
7 from core.custom_decorators import full_profile, login_required
8 from django.conf import settings
9 from django.contrib.auth import get_user_model, login
10 from django.contrib.auth import views as auth_views
11 from django.contrib.auth.mixins import LoginRequiredMixin
12 from django.contrib.sites.shortcuts import get_current_site
13 from django.http import HttpResponseRedirect
14 from django.template.response import TemplateResponse
15 from django.urls import reverse_lazy
16 from django.utils.encoding import force_str
17 from django.utils.http import urlsafe_base64_decode
18 from django.views import View
19 from django.views.generic.edit import FormView, UpdateView
20 
21 from accounts.authentication import account_activation_token, send_activation_email
22 from accounts.forms import ProfileEditForm, UpdateProfileImage, UserRegistrationForm
23 from accounts.models import Profile
24 
25 
26 class RegisterView(FormView):
27     """
28     A form view that handles user registration.
29     """
30 
31     template_name = "accounts/register/register.html"
32     form_class = UserRegistrationForm
33     success_url = "/"
34 
35     def _create_user(self, form):
36         username = form.cleaned_data["username"]
37         password = form.cleaned_data["password"]
38         email = form.cleaned_data["email"]
39         user = get_user_model().objects.create_user(username, email, password)
40         return user
41 
42     def _send_email(self, user):
43         domain = get_current_site(self.request).domain
44         send_activation_email(user, domain)
45 
46     def _login(self, user):
47         login(self.request, user)
48 
49     def form_valid(self, form):
50         user = self._create_user(form)
51 
52         self._send_email(user)
53         self._login(user)
54 
55         return super(RegisterView, self).form_valid(form)
56 
57 
58 class PasswordResetView(auth_views.PasswordResetView):
59     template_name = "accounts/users/password_reset.html"
60     email_template_name = "accounts/users/password_reset_email.html"
61     subject_template_name = "accounts/users/password_reset_subject.txt"
62     from_email = settings.EMAIL_HOST_USER
63     success_url = reverse_lazy("accounts_password_reset_done")
64 
65 
66 class PasswordResetDoneView(auth_views.PasswordResetDoneView):
67     template_name = "accounts/users/password_reset_done.html"
68 
69 
70 class PasswordResetConfirmView(auth_views.PasswordResetConfirmView):
71     template_name = "accounts/users/password_reset_confirm.html"
72     success_url = reverse_lazy("accounts_password_reset_complete")
73 
74 
75 class PasswordResetCompleteView(auth_views.PasswordResetCompleteView):
76     template_name = "accounts/users/password_reset_complete.html"
77 
78 
79 class SettingsView(LoginRequiredMixin, UpdateView):
80     """A form view to edit Profile"""
81 
82     login_url = "accounts_login"
83     form_class = ProfileEditForm
84     success_url = reverse_lazy("accounts_settings")
85     template_name = "accounts/update_settings.html"
86 
87     def get_object(self, queryset=None):
88         return Profile.objects.get(user=self.request.user)
89 
90     def get_initial(self):
91         profile = Profile.objects.get(user=self.request.user)
92         self.initial.update(
93             {
94                 "username": profile.user.username,
95                 "email": profile.user.email,
96                 "first_name": profile.first_name or None,
97                 "last_name": profile.last_name or None,
98                 "about_me": profile.about_me or None,
99             }
100         )
101         return super(SettingsView, self).get_initial()
102 
103 
104 class ProfileActivationView(View):
105     """
106     This shows different views to the user when they are verifying
107     their account based on whether they are already verified or not.
108     """
109 
110     def get(self, request, uidb64, token):
111 
112         User = get_user_model()
113         try:
114             uid = force_str(urlsafe_base64_decode(uidb64))
115             user = User.objects.get(pk=uid)
116 
117         except (TypeError, ValueError, OverflowError, User.DoesNotExist):
118             user = None
119 
120         if user is not None and account_activation_token.check_token(user, token):
121             profile = Profile.objects.get(user=user)
122             if profile.is_verified:
123                 redirect_link = {"href": "/", "label": "Back to Main"}
124                 template_var = {
125                     "title": "Email Already Verified",
126                     "content": "You have already verified your email",
127                     "link": redirect_link,
128                 }
129             else:
130                 profile.is_verified = True
131                 profile.save()
132 
133                 redirect_link = {"href": "/", "label": "Back to Main"}
134                 template_var = {
135                     "title": "Email Verification Successful",
136                     "content": "Thank you for verifying your email with CiviWiki",
137                     "link": redirect_link,
138                 }
139         else:
140             # invalid link
141             redirect_link = {"href": "/", "label": "Back to Main"}
142             template_var = {
143                 "title": "Email Verification Error",
144                 "content": "Email could not be verified",
145                 "link": redirect_link,
146             }
147 
148         return TemplateResponse(request, "general_message.html", template_var)
149 
150 
151 class ProfileSetupView(LoginRequiredMixin, View):
152     """A view to make the user profile full_profile"""
153 
154     login_url = "accounts_login"
155 
156     def get(self, request):
157         profile = Profile.objects.get(user=request.user)
158         if profile.full_profile:
159             return HttpResponseRedirect("/")
160             # start temp rep rendering TODO: REMOVE THIS
161         else:
162             data = {
163                 "username": request.user.username,
164                 "email": request.user.email,
165             }
166             return TemplateResponse(request, "accounts/user-setup.html", data)
167 
168 
169 @login_required
170 @full_profile
171 def user_profile(request, username=None):
172     User = get_user_model()
173     if request.method == "GET":
174         if not username:
175             return HttpResponseRedirect(f"/profile/{request.user}")
176         else:
177             is_owner = username == request.user.username
178             try:
179                 user = User.objects.get(username=username)
180                 profile = user.profile_set.first()
181             except User.DoesNotExist:
182                 return HttpResponseRedirect("/404")
183 
184         form = ProfileEditForm(
185             initial={
186                 "username": user.username,
187                 "email": user.email,
188                 "first_name": profile.first_name or None,
189                 "last_name": profile.last_name or None,
190                 "about_me": profile.about_me or None,
191             },
192             readonly=True,
193         )
194         data = {
195             "username": user,
196             "profile_image_form": UpdateProfileImage,
197             "form": form if is_owner else None,
198             "readonly": True,
199         }
200         return TemplateResponse(request, "account.html", data)
201
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/project/accounts/views.py b/project/accounts/views.py
--- a/project/accounts/views.py
+++ b/project/accounts/views.py
@@ -177,7 +177,6 @@
             is_owner = username == request.user.username
             try:
                 user = User.objects.get(username=username)
-                profile = user.profile_set.first()
             except User.DoesNotExist:
                 return HttpResponseRedirect("/404")
 
@@ -185,9 +184,9 @@
             initial={
                 "username": user.username,
                 "email": user.email,
-                "first_name": profile.first_name or None,
-                "last_name": profile.last_name or None,
-                "about_me": profile.about_me or None,
+                "first_name": user.profile.first_name or None,
+                "last_name": user.profile.last_name or None,
+                "about_me": user.profile.about_me or None,
             },
             readonly=True,
         )

{"golden_diff": "diff --git a/project/accounts/views.py b/project/accounts/views.py\n--- a/project/accounts/views.py\n+++ b/project/accounts/views.py\n@@ -177,7 +177,6 @@\n             is_owner = username == request.user.username\n             try:\n                 user = User.objects.get(username=username)\n-                profile = user.profile_set.first()\n             except User.DoesNotExist:\n                 return HttpResponseRedirect(\"/404\")\n \n@@ -185,9 +184,9 @@\n             initial={\n                 \"username\": user.username,\n                 \"email\": user.email,\n-                \"first_name\": profile.first_name or None,\n-                \"last_name\": profile.last_name or None,\n-                \"about_me\": profile.about_me or None,\n+                \"first_name\": user.profile.first_name or None,\n+                \"last_name\": user.profile.last_name or None,\n+                \"about_me\": user.profile.about_me or None,\n             },\n             readonly=True,\n         )\n", "issue": "[BUG] Fix Bugs when profile is being viewed\n### Description\n\nThe serialization is not correct when the registered user tries to view their own profile\r\n\r\n\r\n\r\nThis comes from the serialization part of our code-base which can be viewed [here](https://github.com/CiviWiki/OpenCiviWiki/blob/develop/project/threads/views.py#L181-L245)\r\n\r\n```py\r\nthread_wiki_data = {\r\n        \"thread_id\": thread_id,\r\n        \"title\": Thread_filter.title,\r\n        \"summary\": Thread_filter.summary,\r\n        \"image\": Thread_filter.image_url,\r\n        \"author\": {\r\n            \"username\": Thread_filter.author.user.username,\r\n            \"profile_image\": Thread_filter.author.profile_image_url,\r\n            \"first_name\": Thread_filter.author.first_name,\r\n            \"last_name\": Thread_filter.author.last_name,\r\n        },\r\n        \"contributors\": [\r\n            Profile.objects.chip_summarize(a)\r\n            for a in Profile.objects.filter(\r\n                pk__in=civis.distinct(\"author\").values_list(\"author\", flat=True)\r\n            )\r\n        ],\r\n        \"category\": {\r\n            \"id\": Thread_filter.category.id,\r\n            \"name\": Thread_filter.category.name,\r\n        },\r\n        \"categories\": [{\"id\": c.id, \"name\": c.name} for c in Category.objects.all()],\r\n        \"created\": Thread_filter.created_date_str,\r\n        \"num_civis\": Thread_filter.num_civis,\r\n        \"num_views\": Thread_filter.num_views,\r\n        \"user_votes\": [\r\n            {\r\n                \"civi_id\": act.civi.id,\r\n                \"activity_type\": act.activity_type,\r\n                \"c_type\": act.civi.c_type,\r\n            }\r\n            for act in Activity.objects.filter(\r\n                thread=Thread_filter.id, account=req_acct.id\r\n            )\r\n        ],\r\n    }\r\n```\n\n### What should have happened?\n\nThe serialization should return user appropriately\n\n### What browser(s) are you seeing the problem on?\n\nChrome, Firefox, Microsoft Edge, Safari\n\n### Further details\n\n![image](https://user-images.githubusercontent.com/67182544/138872174-8fadf9a9-bf2e-40fb-a9b8-7c630ba8a676.png)\n", "before_files": [{"content": "\"\"\"\nClass based views.\n\nThis module will include views for the accounts app.\n\"\"\"\n\nfrom core.custom_decorators import full_profile, login_required\nfrom django.conf import settings\nfrom django.contrib.auth import get_user_model, login\nfrom django.contrib.auth import views as auth_views\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.contrib.sites.shortcuts import get_current_site\nfrom django.http import HttpResponseRedirect\nfrom django.template.response import TemplateResponse\nfrom django.urls import reverse_lazy\nfrom django.utils.encoding import force_str\nfrom django.utils.http import urlsafe_base64_decode\nfrom django.views import View\nfrom django.views.generic.edit import FormView, UpdateView\n\nfrom accounts.authentication import account_activation_token, send_activation_email\nfrom accounts.forms import ProfileEditForm, UpdateProfileImage, UserRegistrationForm\nfrom accounts.models import Profile\n\n\nclass RegisterView(FormView):\n    \"\"\"\n    A form view that handles user registration.\n    \"\"\"\n\n    template_name = \"accounts/register/register.html\"\n    form_class = UserRegistrationForm\n    success_url = \"/\"\n\n    def _create_user(self, form):\n        username = form.cleaned_data[\"username\"]\n        password = form.cleaned_data[\"password\"]\n        email = form.cleaned_data[\"email\"]\n        user = get_user_model().objects.create_user(username, email, password)\n        return user\n\n    def _send_email(self, user):\n        domain = get_current_site(self.request).domain\n        send_activation_email(user, domain)\n\n    def _login(self, user):\n        login(self.request, user)\n\n    def form_valid(self, form):\n        user = self._create_user(form)\n\n        self._send_email(user)\n        self._login(user)\n\n        return super(RegisterView, self).form_valid(form)\n\n\nclass PasswordResetView(auth_views.PasswordResetView):\n    template_name = \"accounts/users/password_reset.html\"\n    email_template_name = \"accounts/users/password_reset_email.html\"\n    subject_template_name = \"accounts/users/password_reset_subject.txt\"\n    from_email = settings.EMAIL_HOST_USER\n    success_url = reverse_lazy(\"accounts_password_reset_done\")\n\n\nclass PasswordResetDoneView(auth_views.PasswordResetDoneView):\n    template_name = \"accounts/users/password_reset_done.html\"\n\n\nclass PasswordResetConfirmView(auth_views.PasswordResetConfirmView):\n    template_name = \"accounts/users/password_reset_confirm.html\"\n    success_url = reverse_lazy(\"accounts_password_reset_complete\")\n\n\nclass PasswordResetCompleteView(auth_views.PasswordResetCompleteView):\n    template_name = \"accounts/users/password_reset_complete.html\"\n\n\nclass SettingsView(LoginRequiredMixin, UpdateView):\n    \"\"\"A form view to edit Profile\"\"\"\n\n    login_url = \"accounts_login\"\n    form_class = ProfileEditForm\n    success_url = reverse_lazy(\"accounts_settings\")\n    template_name = \"accounts/update_settings.html\"\n\n    def get_object(self, queryset=None):\n        return Profile.objects.get(user=self.request.user)\n\n    def get_initial(self):\n        profile = Profile.objects.get(user=self.request.user)\n        self.initial.update(\n            {\n                \"username\": profile.user.username,\n                \"email\": profile.user.email,\n                \"first_name\": profile.first_name or None,\n                \"last_name\": profile.last_name or None,\n                \"about_me\": profile.about_me or None,\n            }\n        )\n        return super(SettingsView, self).get_initial()\n\n\nclass ProfileActivationView(View):\n    \"\"\"\n    This shows different views to the user when they are verifying\n    their account based on whether they are already verified or not.\n    \"\"\"\n\n    def get(self, request, uidb64, token):\n\n        User = get_user_model()\n        try:\n            uid = force_str(urlsafe_base64_decode(uidb64))\n            user = User.objects.get(pk=uid)\n\n        except (TypeError, ValueError, OverflowError, User.DoesNotExist):\n            user = None\n\n        if user is not None and account_activation_token.check_token(user, token):\n            profile = Profile.objects.get(user=user)\n            if profile.is_verified:\n                redirect_link = {\"href\": \"/\", \"label\": \"Back to Main\"}\n                template_var = {\n                    \"title\": \"Email Already Verified\",\n                    \"content\": \"You have already verified your email\",\n                    \"link\": redirect_link,\n                }\n            else:\n                profile.is_verified = True\n                profile.save()\n\n                redirect_link = {\"href\": \"/\", \"label\": \"Back to Main\"}\n                template_var = {\n                    \"title\": \"Email Verification Successful\",\n                    \"content\": \"Thank you for verifying your email with CiviWiki\",\n                    \"link\": redirect_link,\n                }\n        else:\n            # invalid link\n            redirect_link = {\"href\": \"/\", \"label\": \"Back to Main\"}\n            template_var = {\n                \"title\": \"Email Verification Error\",\n                \"content\": \"Email could not be verified\",\n                \"link\": redirect_link,\n            }\n\n        return TemplateResponse(request, \"general_message.html\", template_var)\n\n\nclass ProfileSetupView(LoginRequiredMixin, View):\n    \"\"\"A view to make the user profile full_profile\"\"\"\n\n    login_url = \"accounts_login\"\n\n    def get(self, request):\n        profile = Profile.objects.get(user=request.user)\n        if profile.full_profile:\n            return HttpResponseRedirect(\"/\")\n            # start temp rep rendering TODO: REMOVE THIS\n        else:\n            data = {\n                \"username\": request.user.username,\n                \"email\": request.user.email,\n            }\n            return TemplateResponse(request, \"accounts/user-setup.html\", data)\n\n\n@login_required\n@full_profile\ndef user_profile(request, username=None):\n    User = get_user_model()\n    if request.method == \"GET\":\n        if not username:\n            return HttpResponseRedirect(f\"/profile/{request.user}\")\n        else:\n            is_owner = username == request.user.username\n            try:\n                user = User.objects.get(username=username)\n                profile = user.profile_set.first()\n            except User.DoesNotExist:\n                return HttpResponseRedirect(\"/404\")\n\n        form = ProfileEditForm(\n            initial={\n                \"username\": user.username,\n                \"email\": user.email,\n                \"first_name\": profile.first_name or None,\n                \"last_name\": profile.last_name or None,\n                \"about_me\": profile.about_me or None,\n            },\n            readonly=True,\n        )\n        data = {\n            \"username\": user,\n            \"profile_image_form\": UpdateProfileImage,\n            \"form\": form if is_owner else None,\n            \"readonly\": True,\n        }\n        return TemplateResponse(request, \"account.html\", data)\n", "path": "project/accounts/views.py"}], "after_files": [{"content": "\"\"\"\nClass based views.\n\nThis module will include views for the accounts app.\n\"\"\"\n\nfrom core.custom_decorators import full_profile, login_required\nfrom django.conf import settings\nfrom django.contrib.auth import get_user_model, login\nfrom django.contrib.auth import views as auth_views\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.contrib.sites.shortcuts import get_current_site\nfrom django.http import HttpResponseRedirect\nfrom django.template.response import TemplateResponse\nfrom django.urls import reverse_lazy\nfrom django.utils.encoding import force_str\nfrom django.utils.http import urlsafe_base64_decode\nfrom django.views import View\nfrom django.views.generic.edit import FormView, UpdateView\n\nfrom accounts.authentication import account_activation_token, send_activation_email\nfrom accounts.forms import ProfileEditForm, UpdateProfileImage, UserRegistrationForm\nfrom accounts.models import Profile\n\n\nclass RegisterView(FormView):\n    \"\"\"\n    A form view that handles user registration.\n    \"\"\"\n\n    template_name = \"accounts/register/register.html\"\n    form_class = UserRegistrationForm\n    success_url = \"/\"\n\n    def _create_user(self, form):\n        username = form.cleaned_data[\"username\"]\n        password = form.cleaned_data[\"password\"]\n        email = form.cleaned_data[\"email\"]\n        user = get_user_model().objects.create_user(username, email, password)\n        return user\n\n    def _send_email(self, user):\n        domain = get_current_site(self.request).domain\n        send_activation_email(user, domain)\n\n    def _login(self, user):\n        login(self.request, user)\n\n    def form_valid(self, form):\n        user = self._create_user(form)\n\n        self._send_email(user)\n        self._login(user)\n\n        return super(RegisterView, self).form_valid(form)\n\n\nclass PasswordResetView(auth_views.PasswordResetView):\n    template_name = \"accounts/users/password_reset.html\"\n    email_template_name = \"accounts/users/password_reset_email.html\"\n    subject_template_name = \"accounts/users/password_reset_subject.txt\"\n    from_email = settings.EMAIL_HOST_USER\n    success_url = reverse_lazy(\"accounts_password_reset_done\")\n\n\nclass PasswordResetDoneView(auth_views.PasswordResetDoneView):\n    template_name = \"accounts/users/password_reset_done.html\"\n\n\nclass PasswordResetConfirmView(auth_views.PasswordResetConfirmView):\n    template_name = \"accounts/users/password_reset_confirm.html\"\n    success_url = reverse_lazy(\"accounts_password_reset_complete\")\n\n\nclass PasswordResetCompleteView(auth_views.PasswordResetCompleteView):\n    template_name = \"accounts/users/password_reset_complete.html\"\n\n\nclass SettingsView(LoginRequiredMixin, UpdateView):\n    \"\"\"A form view to edit Profile\"\"\"\n\n    login_url = \"accounts_login\"\n    form_class = ProfileEditForm\n    success_url = reverse_lazy(\"accounts_settings\")\n    template_name = \"accounts/update_settings.html\"\n\n    def get_object(self, queryset=None):\n        return Profile.objects.get(user=self.request.user)\n\n    def get_initial(self):\n        profile = Profile.objects.get(user=self.request.user)\n        self.initial.update(\n            {\n                \"username\": profile.user.username,\n                \"email\": profile.user.email,\n                \"first_name\": profile.first_name or None,\n                \"last_name\": profile.last_name or None,\n                \"about_me\": profile.about_me or None,\n            }\n        )\n        return super(SettingsView, self).get_initial()\n\n\nclass ProfileActivationView(View):\n    \"\"\"\n    This shows different views to the user when they are verifying\n    their account based on whether they are already verified or not.\n    \"\"\"\n\n    def get(self, request, uidb64, token):\n\n        User = get_user_model()\n        try:\n            uid = force_str(urlsafe_base64_decode(uidb64))\n            user = User.objects.get(pk=uid)\n\n        except (TypeError, ValueError, OverflowError, User.DoesNotExist):\n            user = None\n\n        if user is not None and account_activation_token.check_token(user, token):\n            profile = Profile.objects.get(user=user)\n            if profile.is_verified:\n                redirect_link = {\"href\": \"/\", \"label\": \"Back to Main\"}\n                template_var = {\n                    \"title\": \"Email Already Verified\",\n                    \"content\": \"You have already verified your email\",\n                    \"link\": redirect_link,\n                }\n            else:\n                profile.is_verified = True\n                profile.save()\n\n                redirect_link = {\"href\": \"/\", \"label\": \"Back to Main\"}\n                template_var = {\n                    \"title\": \"Email Verification Successful\",\n                    \"content\": \"Thank you for verifying your email with CiviWiki\",\n                    \"link\": redirect_link,\n                }\n        else:\n            # invalid link\n            redirect_link = {\"href\": \"/\", \"label\": \"Back to Main\"}\n            template_var = {\n                \"title\": \"Email Verification Error\",\n                \"content\": \"Email could not be verified\",\n                \"link\": redirect_link,\n            }\n\n        return TemplateResponse(request, \"general_message.html\", template_var)\n\n\nclass ProfileSetupView(LoginRequiredMixin, View):\n    \"\"\"A view to make the user profile full_profile\"\"\"\n\n    login_url = \"accounts_login\"\n\n    def get(self, request):\n        profile = Profile.objects.get(user=request.user)\n        if profile.full_profile:\n            return HttpResponseRedirect(\"/\")\n            # start temp rep rendering TODO: REMOVE THIS\n        else:\n            data = {\n                \"username\": request.user.username,\n                \"email\": request.user.email,\n            }\n            return TemplateResponse(request, \"accounts/user-setup.html\", data)\n\n\n@login_required\n@full_profile\ndef user_profile(request, username=None):\n    User = get_user_model()\n    if request.method == \"GET\":\n        if not username:\n            return HttpResponseRedirect(f\"/profile/{request.user}\")\n        else:\n            is_owner = username == request.user.username\n            try:\n                user = User.objects.get(username=username)\n            except User.DoesNotExist:\n                return HttpResponseRedirect(\"/404\")\n\n        form = ProfileEditForm(\n            initial={\n                \"username\": user.username,\n                \"email\": user.email,\n                \"first_name\": user.profile.first_name or None,\n                \"last_name\": user.profile.last_name or None,\n                \"about_me\": user.profile.about_me or None,\n            },\n            readonly=True,\n        )\n        data = {\n            \"username\": user,\n            \"profile_image_form\": UpdateProfileImage,\n            \"form\": form if is_owner else None,\n            \"readonly\": True,\n        }\n        return TemplateResponse(request, \"account.html\", data)\n", "path": "project/accounts/views.py"}]}