diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4f215f8..fa64e20 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,15 @@
-
+
+
+
-
+
+
+
+
+
@@ -111,7 +117,8 @@
-
+
+
@@ -161,7 +168,15 @@
1704404638083
-
+
+
+ 1704480250935
+
+
+
+ 1704480250935
+
+
@@ -174,6 +189,7 @@
-
+
+
\ No newline at end of file
diff --git a/chat/migrations/0004_alter_message_image.py b/chat/migrations/0004_alter_message_image.py
new file mode 100644
index 0000000..eba3ecf
--- /dev/null
+++ b/chat/migrations/0004_alter_message_image.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0 on 2024-01-05 21:33
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('chat', '0003_message_image'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='message',
+ name='image',
+ field=models.CharField(blank=True, max_length=500, null=True),
+ ),
+ ]
diff --git a/db.sqlite3 b/db.sqlite3
index 7873380..f310c9d 100644
Binary files a/db.sqlite3 and b/db.sqlite3 differ
diff --git a/templates/panel/base.html b/templates/panel/base.html
index 6a7c987..f836e41 100644
--- a/templates/panel/base.html
+++ b/templates/panel/base.html
@@ -16,16 +16,16 @@
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/users/forms.py b/users/forms.py
index 6ee6d6e..db3ebe6 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -1,6 +1,6 @@
from django import forms
from users.models import User
-from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.forms import UserCreationForm,UserChangeForm
class RegisterForm(UserCreationForm):
# fields we want to include and customize in our form
@@ -43,3 +43,40 @@ class Meta:
fields = ['first_name', 'last_name', 'username', 'email', 'password1', 'password2']
+
+class ProfileForm(UserChangeForm):
+ # fields we want to include and customize in our form
+ first_name = forms.CharField(max_length=100,
+ required=True,
+ widget=forms.TextInput(attrs={'placeholder': 'First Name',
+ 'class': 'form-control col-md-6',
+ }))
+ last_name = forms.CharField(max_length=100,
+ required=True,
+ widget=forms.TextInput(attrs={'placeholder': 'Last Name',
+ 'class': 'form-control col-md-6',
+ }))
+ username = forms.CharField(max_length=100,
+ required=True,
+ widget=forms.TextInput(attrs={'placeholder': 'Username',
+ 'class': 'form-control col-md-6',
+ }))
+ email = forms.EmailField(required=False,
+ widget=forms.EmailInput(attrs={'placeholder': 'Email',
+ 'class': 'form-control col-md-6',
+ }))
+
+ bio = forms.CharField(max_length=255,
+ required=False,
+ widget=forms.Textarea(attrs={'placeholder': 'bio',
+ 'class': 'form-control',
+ 'data-toggle': 'bio',
+ 'id': 'bio',
+ }))
+ password = None
+
+ class Meta:
+ model = User
+ fields = ['first_name', 'last_name', 'username', 'email', 'image', 'bio']
+
+
diff --git a/users/migrations/0004_user_bio.py b/users/migrations/0004_user_bio.py
new file mode 100644
index 0000000..e6861ad
--- /dev/null
+++ b/users/migrations/0004_user_bio.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0 on 2024-01-05 21:33
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0003_alter_user_image'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='user',
+ name='bio',
+ field=models.TextField(blank=True, max_length=255, null=True),
+ ),
+ ]
diff --git a/users/models.py b/users/models.py
index 6c9074b..f40f264 100644
--- a/users/models.py
+++ b/users/models.py
@@ -4,3 +4,4 @@
# Create your models here.
class User(AbstractUser):
image = models.ImageField(upload_to='users/%Y/%m/', blank=True,null=True)
+ bio = models.TextField(max_length=255, blank=True,null=True)
diff --git a/users/urls.py b/users/urls.py
index c0a8cb2..0d6a058 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -8,5 +8,6 @@
# login auth user model
path("login/", auth_views.LoginView.as_view(template_name='chat/login.html'), name='login'),
# register have a view
- path('register/', views.RegisterView.as_view(), name='register')
+ path('register/', views.RegisterView.as_view(), name='register'),
+ path("profile/",views.Profile.as_view(),name='profile')
]
\ No newline at end of file
diff --git a/users/views.py b/users/views.py
index aa25b12..e51e9f0 100644
--- a/users/views.py
+++ b/users/views.py
@@ -5,7 +5,8 @@
from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.views import View
-
+from django.views.generic import UpdateView, DetailView
+from users.forms import ProfileForm
from chat import models
from users.forms import RegisterForm
from users.models import User
@@ -78,4 +79,15 @@ def post(self, request, *args, **kwargs):
return redirect(to='/')
- return render(request, self.template_name, {'form': form})
\ No newline at end of file
+ return render(request, self.template_name, {'form': form})
+
+
+
+# Detail Profile
+class Profile(UpdateView,DetailView):
+ model = User
+ template_name = 'panel/profile.html'
+ form_class = ProfileForm
+ success_url = reverse_lazy("profile")
+ def get_object(self):
+ return User.objects.get(pk = self.request.user.pk)
\ No newline at end of file