From c35952667e493583ee6952a8edcc480f7fd135db Mon Sep 17 00:00:00 2001 From: TimOsahenru Date: Tue, 1 Nov 2022 14:36:55 +0000 Subject: [PATCH 1/3] user categories to profile --- project/accounts/forms.py | 8 +++++++ .../accounts/templates/accounts/account.html | 23 +++++++++++-------- .../accounts/templates/accounts/settings.html | 6 ++--- project/accounts/views.py | 3 +++ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/project/accounts/forms.py b/project/accounts/forms.py index af0d18db..1b30594c 100644 --- a/project/accounts/forms.py +++ b/project/accounts/forms.py @@ -110,6 +110,7 @@ class ProfileEditForm(forms.ModelForm): class Meta: model = Profile + fields = [ "first_name", "last_name", @@ -117,7 +118,9 @@ class Meta: "profile_image", "username", "email", + "categories", ] + widgets = {"categories": forms.CheckboxSelectMultiple()} first_name = forms.CharField(label="First Name", max_length=63, required=False) last_name = forms.CharField(label="Last Name", max_length=63, required=False) @@ -125,6 +128,11 @@ class Meta: email = forms.EmailField(label="Email", disabled=True) username = forms.CharField(label="Username", disabled=True) profile_image = forms.ImageField(required=False) + # categories = forms.ModelMultipleChoiceField( + # queryset=Category.objects.all(), + # required=False, + # widget=forms.CheckboxSelectMultiple + # ) class UpdatePassword(forms.ModelForm): diff --git a/project/accounts/templates/accounts/account.html b/project/accounts/templates/accounts/account.html index e9c6602b..cbf49e6b 100644 --- a/project/accounts/templates/accounts/account.html +++ b/project/accounts/templates/accounts/account.html @@ -22,15 +22,15 @@ {% if not profile == request.user.profile %} - {% if profile not in request.user.profile.following.all %} - - follow - - {% else %} - - unfollow - - {% endif %} + {% if profile not in request.user.profile.following.all %} + + follow + + {% else %} + + unfollow + + {% endif %} {% endif %}
@@ -45,6 +45,11 @@
ABOUT ME
{{ profile.about_me }}
+
+
CATEGORIES
+ {% for category in categories %} +
{{ category.name }}
+ {% endfor %}
diff --git a/project/accounts/templates/accounts/settings.html b/project/accounts/templates/accounts/settings.html index 8fb956d2..67fface2 100644 --- a/project/accounts/templates/accounts/settings.html +++ b/project/accounts/templates/accounts/settings.html @@ -68,9 +68,9 @@
- {%if not readonly %} + {% if not readonly %} - {% endif%} + {% endif %}
@@ -86,7 +86,7 @@