diff --git a/sahara/db.sqlite3 b/sahara/db.sqlite3
index e69de29..3c6d0fb 100644
Binary files a/sahara/db.sqlite3 and b/sahara/db.sqlite3 differ
diff --git a/sahara/main/__pycache__/__init__.cpython-312.pyc b/sahara/main/__pycache__/__init__.cpython-312.pyc
index 6062845..08c17ff 100644
Binary files a/sahara/main/__pycache__/__init__.cpython-312.pyc and b/sahara/main/__pycache__/__init__.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/admin.cpython-312.pyc b/sahara/main/__pycache__/admin.cpython-312.pyc
index 8b1ada4..00e14cd 100644
Binary files a/sahara/main/__pycache__/admin.cpython-312.pyc and b/sahara/main/__pycache__/admin.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/apps.cpython-312.pyc b/sahara/main/__pycache__/apps.cpython-312.pyc
index 3a5ab1a..8d62f81 100644
Binary files a/sahara/main/__pycache__/apps.cpython-312.pyc and b/sahara/main/__pycache__/apps.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/forms.cpython-312.pyc b/sahara/main/__pycache__/forms.cpython-312.pyc
new file mode 100644
index 0000000..c5b5796
Binary files /dev/null and b/sahara/main/__pycache__/forms.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/managers.cpython-312.pyc b/sahara/main/__pycache__/managers.cpython-312.pyc
new file mode 100644
index 0000000..4369e48
Binary files /dev/null and b/sahara/main/__pycache__/managers.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/models.cpython-312.pyc b/sahara/main/__pycache__/models.cpython-312.pyc
index 65b9d32..8ced3f8 100644
Binary files a/sahara/main/__pycache__/models.cpython-312.pyc and b/sahara/main/__pycache__/models.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/urls.cpython-312.pyc b/sahara/main/__pycache__/urls.cpython-312.pyc
index 2af993b..1bc0233 100644
Binary files a/sahara/main/__pycache__/urls.cpython-312.pyc and b/sahara/main/__pycache__/urls.cpython-312.pyc differ
diff --git a/sahara/main/__pycache__/views.cpython-312.pyc b/sahara/main/__pycache__/views.cpython-312.pyc
index c232a21..3454408 100644
Binary files a/sahara/main/__pycache__/views.cpython-312.pyc and b/sahara/main/__pycache__/views.cpython-312.pyc differ
diff --git a/sahara/main/admin.py b/sahara/main/admin.py
index 8c38f3f..29298ee 100644
--- a/sahara/main/admin.py
+++ b/sahara/main/admin.py
@@ -1,3 +1,8 @@
from django.contrib import admin
+from .models import BaseUser,Role
+
# Register your models here.
+
+admin.site.register(BaseUser)
+admin.site.register(Role)
diff --git a/sahara/main/creds.txt b/sahara/main/creds.txt
deleted file mode 100644
index 3e3b93a..0000000
--- a/sahara/main/creds.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-app_password ="duse xjaj pxkg wyur"
-app_email = "dmyemail254@gmail.com"
\ No newline at end of file
diff --git a/sahara/main/forms.py b/sahara/main/forms.py
new file mode 100644
index 0000000..b8a7f9a
--- /dev/null
+++ b/sahara/main/forms.py
@@ -0,0 +1,45 @@
+from django import forms
+from django.contrib.auth.forms import UserCreationForm
+from .models import BaseUser
+
+class BaseUserForm(UserCreationForm):
+ class Meta:
+ model = BaseUser
+ fields = [
+ 'first_name',
+ 'last_name',
+ 'bio',
+ 'address',
+ 'contact_number',
+ 'image',
+ 'citizenship',
+ 'certificate',
+ 'price',
+ 'role',
+ 'email',
+ ]
+ password1 = forms.CharField(
+ widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Password'}),
+ label='Password',
+ min_length=8,
+ )
+ password2 = forms.CharField(
+ widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': 'Confirm Password'}),
+ label='Confirm Password',
+ min_length=8,
+ )
+
+ def clean_password2(self):
+ password1 = self.cleaned_data.get('password1')
+ password2 = self.cleaned_data.get('password2')
+
+ if password1 and password2 and password1 != password2:
+ raise forms.ValidationError("Passwords don't match.")
+ return password2
+
+ def save(self, commit=True):
+ user = super().save(commit=False)
+ user.set_password(self.cleaned_data['password1'])
+ if commit:
+ user.save()
+ return user
diff --git a/sahara/main/migrations/0001_initial.py b/sahara/main/migrations/0001_initial.py
new file mode 100644
index 0000000..72bd337
--- /dev/null
+++ b/sahara/main/migrations/0001_initial.py
@@ -0,0 +1,64 @@
+# Generated by Django 5.1.4 on 2025-01-11 11:43
+
+import django.contrib.auth.models
+import django.db.models.deletion
+import django.utils.timezone
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('auth', '0012_alter_user_first_name_max_length'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Role',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('role', models.CharField(max_length=20)),
+ ('role_desc', models.TextField()),
+ ],
+ ),
+ migrations.CreateModel(
+ name='BaseUser',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('password', models.CharField(max_length=128, verbose_name='password')),
+ ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
+ ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
+ ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
+ ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
+ ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
+ ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
+ ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
+ ('image', models.ImageField(blank=True, null=True, upload_to='')),
+ ('bio', models.TextField(blank=True, null=True)),
+ ('address', models.CharField(blank=True, max_length=50, null=True)),
+ ('contact_number', models.CharField(blank=True, max_length=15, null=True, unique=True)),
+ ('email', models.EmailField(max_length=254, unique=True)),
+ ('citizenship', models.FileField(blank=True, null=True, upload_to='uploads/citizenship')),
+ ('certificate', models.FileField(blank=True, null=True, upload_to='uploads/certificates')),
+ ('token', models.CharField(blank=True, max_length=64, null=True)),
+ ('is_verified', models.BooleanField(default=False)),
+ ('price', models.DecimalField(blank=True, decimal_places=2, max_digits=9999, null=True)),
+ ('ratings', models.IntegerField(default=1)),
+ ('member_since', models.DateTimeField(auto_now_add=True)),
+ ('profile_updated', models.DateTimeField(auto_now=True)),
+ ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
+ ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
+ ('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='users', to='main.role')),
+ ],
+ options={
+ 'verbose_name': 'user',
+ 'verbose_name_plural': 'users',
+ 'abstract': False,
+ },
+ managers=[
+ ('objects', django.contrib.auth.models.UserManager()),
+ ],
+ ),
+ ]
diff --git a/sahara/main/migrations/__pycache__/0001_initial.cpython-312.pyc b/sahara/main/migrations/__pycache__/0001_initial.cpython-312.pyc
new file mode 100644
index 0000000..8ac686c
Binary files /dev/null and b/sahara/main/migrations/__pycache__/0001_initial.cpython-312.pyc differ
diff --git a/sahara/main/migrations/__pycache__/0002_alter_baseuser_options_baseuser_date_joined_and_more.cpython-312.pyc b/sahara/main/migrations/__pycache__/0002_alter_baseuser_options_baseuser_date_joined_and_more.cpython-312.pyc
new file mode 100644
index 0000000..bf1341d
Binary files /dev/null and b/sahara/main/migrations/__pycache__/0002_alter_baseuser_options_baseuser_date_joined_and_more.cpython-312.pyc differ
diff --git a/sahara/main/migrations/__pycache__/0003_remove_baseuser_role.cpython-312.pyc b/sahara/main/migrations/__pycache__/0003_remove_baseuser_role.cpython-312.pyc
new file mode 100644
index 0000000..945339c
Binary files /dev/null and b/sahara/main/migrations/__pycache__/0003_remove_baseuser_role.cpython-312.pyc differ
diff --git a/sahara/main/migrations/__pycache__/0004_alter_baseuser_managers_baseuser_role.cpython-312.pyc b/sahara/main/migrations/__pycache__/0004_alter_baseuser_managers_baseuser_role.cpython-312.pyc
new file mode 100644
index 0000000..efc3cce
Binary files /dev/null and b/sahara/main/migrations/__pycache__/0004_alter_baseuser_managers_baseuser_role.cpython-312.pyc differ
diff --git a/sahara/main/migrations/__pycache__/0005_alter_baseuser_managers.cpython-312.pyc b/sahara/main/migrations/__pycache__/0005_alter_baseuser_managers.cpython-312.pyc
new file mode 100644
index 0000000..94be69c
Binary files /dev/null and b/sahara/main/migrations/__pycache__/0005_alter_baseuser_managers.cpython-312.pyc differ
diff --git a/sahara/main/migrations/__pycache__/0006_remove_baseuser_username.cpython-312.pyc b/sahara/main/migrations/__pycache__/0006_remove_baseuser_username.cpython-312.pyc
new file mode 100644
index 0000000..b2f6519
Binary files /dev/null and b/sahara/main/migrations/__pycache__/0006_remove_baseuser_username.cpython-312.pyc differ
diff --git a/sahara/main/migrations/__pycache__/__init__.cpython-312.pyc b/sahara/main/migrations/__pycache__/__init__.cpython-312.pyc
index 71c3498..aac4277 100644
Binary files a/sahara/main/migrations/__pycache__/__init__.cpython-312.pyc and b/sahara/main/migrations/__pycache__/__init__.cpython-312.pyc differ
diff --git a/sahara/main/models.py b/sahara/main/models.py
index c1611fc..9341214 100644
--- a/sahara/main/models.py
+++ b/sahara/main/models.py
@@ -1,32 +1,43 @@
from django.db import models
-from django.contrib.auth.models import User
+from django.contrib.auth.models import AbstractUser
+from django.dispatch import receiver
+from django.db.models.signals import post_save
+
+
-# Create your models here.
class Role(models.Model):
role = models.CharField(max_length=20)
role_desc = models.TextField()
def __str__(self):
- return self.role
-
+ return self.role
-class BaseUser(models.Model):
- user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="user")
- image = models.ImageField()
+class BaseUser(AbstractUser):
+ username = None
+ image = models.ImageField(null=True, blank=True)
bio = models.TextField(null=True, blank=True)
address = models.CharField(null=True, blank=True, max_length=50)
- contact_number = models.CharField(unique=True, max_length=15)
+ contact_number = models.CharField(unique=True, max_length=15, null=True, blank=True)
email = models.EmailField(unique=True)
- citizenship = models.FileField(upload_to ='uploads/citizenship')
- certificate = models.FileField(upload_to='uploads/certificates')
- is_activated = models.BooleanField(default=False)
+ citizenship = models.FileField(upload_to='uploads/citizenship', null=True, blank=True)
+ certificate = models.FileField(upload_to='uploads/certificates', blank=True, null=True)
+ #is_activated = models.BooleanField(default=False)
+ token = models.CharField(max_length=64,blank=True,null=True)
is_verified = models.BooleanField(default=False)
- price = models.DecimalField(max_digits=9999,decimal_places=2)
- ratings = models.PositiveIntegerField()
- role = models.ForeignKey(Role, on_delete=models.CASCADE, related_name="user_role")
- def __str__(self):
- return self.user.username
- USERNAME_FIELD = "email"
+ price = models.DecimalField(max_digits=9999, decimal_places=2, null=True, blank=True)
+ ratings = models.IntegerField(default=1)
+ role = models.ForeignKey('Role', on_delete=models.SET_NULL, related_name="users", null=True, blank=True)
+ member_since = models.DateTimeField(auto_now_add=True)
+ profile_updated = models.DateTimeField(auto_now=True)
+ USERNAME_FIELD = "email"
+ REQUIRED_FIELDS = ["image", "contact_number", "bio", "address", "citizenship", "certificate", "price", "password"]
+ def __str__(self):
+ return self.email
+
+ @receiver(post_save, sender=AbstractUser)
+ def user_to_inactive(sender, instance, created, update_fields, **kwargs):
+ if created:
+ instance.is_active = False
diff --git a/sahara/main/templates/main/create_user.html b/sahara/main/templates/main/create_user.html
new file mode 100644
index 0000000..fe40825
--- /dev/null
+++ b/sahara/main/templates/main/create_user.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
diff --git a/sahara/main/templates/main/delete_user.html b/sahara/main/templates/main/delete_user.html
new file mode 100644
index 0000000..296dbec
--- /dev/null
+++ b/sahara/main/templates/main/delete_user.html
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/sahara/main/templates/main/mail/welcome_email.html b/sahara/main/templates/main/mail/welcome_email.html
new file mode 100644
index 0000000..9e0c961
--- /dev/null
+++ b/sahara/main/templates/main/mail/welcome_email.html
@@ -0,0 +1,65 @@
+{% load static %}
+
+
+
+
+
+
+ Welcome to Sahara
+
+
+
+
+
Welcome to Sahara!
+
+
Hello {{ user.first_name }},
+
Thank you for signing up with Sahara! We're excited to have you on board.
+
Please click the button below to activate your account:
+
Activate Your Account
+
If you did not sign up for this account, please ignore this email.
+
Best regards, Sahara Team
+
+
+
diff --git a/sahara/main/templates/main/mail/welcome_email.txt b/sahara/main/templates/main/mail/welcome_email.txt
new file mode 100644
index 0000000..4d772dc
--- /dev/null
+++ b/sahara/main/templates/main/mail/welcome_email.txt
@@ -0,0 +1,14 @@
+Welcome to Sahara!
+
+Hello {{ user.first_name }},
+
+Thank you for signing up with Sahara! We're excited to have you on board.
+
+Please click the link below to activate your account:
+
+{{ activation_link }}
+
+If you did not sign up for this account, please ignore this email.
+
+Best regards,
+Sahara Team
diff --git a/sahara/main/templates/main/update_user.html b/sahara/main/templates/main/update_user.html
new file mode 100644
index 0000000..ad40f5f
--- /dev/null
+++ b/sahara/main/templates/main/update_user.html
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/sahara/main/templates/main/user_list.html b/sahara/main/templates/main/user_list.html
new file mode 100644
index 0000000..f534d95
--- /dev/null
+++ b/sahara/main/templates/main/user_list.html
@@ -0,0 +1,5 @@
+
+{% for user in users %}
+ {{ user }}
+ (delete)
+{% endfor %}
\ No newline at end of file
diff --git a/sahara/main/urls.py b/sahara/main/urls.py
index 95d2499..33d5cee 100644
--- a/sahara/main/urls.py
+++ b/sahara/main/urls.py
@@ -1,7 +1,9 @@
-from django.contrib import admin
-from django.urls import path, include
-from .views import homeView
+from django.urls import path
+from .views import homeView,send_mail_page,createUserView,activate_account
urlpatterns = [
path('',homeView, name="home"),
+ path('send-email/',send_mail_page,name="sendmail"),
+ path('user/register/',createUserView,name="register"),
+ path('activate//', activate_account, name='activate'),
]
diff --git a/sahara/main/utilities.py b/sahara/main/utilities.py
new file mode 100644
index 0000000..83705ba
--- /dev/null
+++ b/sahara/main/utilities.py
@@ -0,0 +1,26 @@
+from django.core.mail import send_mail
+from django.template.loader import render_to_string
+from django.utils.html import strip_tags
+from django.conf import settings
+from django.urls import reverse
+from django.contrib.sites.shortcuts import get_current_site
+from django.contrib.auth.tokens import default_token_generator
+
+def send_welcome_email(user, request):
+ token = 'generated_token_here'
+ activation_link = f"{get_current_site(request).domain}{reverse('account:activate', args=[token])}"
+ subject = "Welcome to Sahara - Please Activate Your Account"
+
+ html_message = render_to_string('welcome_email.html', {
+ 'user': user,
+ 'activation_link': activation_link,
+ })
+ plain_message = strip_tags(html_message)
+
+ send_mail(
+ subject,
+ plain_message,
+ settings.DEFAULT_FROM_EMAIL,
+ [user.email],
+ html_message=html_message,
+ )
diff --git a/sahara/main/views.py b/sahara/main/views.py
index eb227f9..449ef55 100644
--- a/sahara/main/views.py
+++ b/sahara/main/views.py
@@ -1,7 +1,91 @@
-from django.shortcuts import render,HttpResponse
-
-
+from django.shortcuts import render,redirect,HttpResponse
+from django.core.mail import send_mail
+from django.conf import settings
+from django.template.loader import render_to_string
+from django.utils.html import strip_tags
+from django.conf import settings
+from django.urls import reverse
+from django.contrib.sites.shortcuts import get_current_site
+from . forms import BaseUserForm
+from django.contrib import messages
+from django.contrib.auth.tokens import default_token_generator
# Create your views here.
+from .models import BaseUser
+
def homeView(request):
- return HttpResponse("Home Page ")
\ No newline at end of file
+ return HttpResponse("home")
+
+def createUserView(request):
+ if request.method == 'POST':
+ form = BaseUserForm(request.POST, request.FILES)
+ print(form)
+ if form.is_valid():
+ form.save()
+ form.is_a
+ #return redirect('home')
+ return HttpResponse("User Created ")
+ else:
+ form = BaseUserForm()
+ return render(request, 'main/create_user.html', {
+ 'form': form
+ })
+
+
+def send_mail_page():
+ address = "sajeshmaan@gmail.com"
+ subject = "Congrts Team Flash"
+ message = "Congrts Team Flash hackx committe has announced your team as a winner"
+ try:
+ send_mail(subject, message, settings.EMAIL_HOST_USER, [address,'rajakiaryal0@gmail.com'])
+ result= 'Email sent successfully'
+ except Exception as e:
+ result = f'Error sending email: {e}'
+
+
+def send_welcome_email(user, request):
+ # Generate activation link
+ user = BaseUser.objects.get(email="user@example.com") # Replace with your user object
+ token = default_token_generator.make_token(user)
+ token = 'generated_token_here' # This token will be generated based on your activation logic
+ activation_link = f"{get_current_site(request).domain}{reverse('account:activate', args=[token])}"
+
+ # Prepare email subject and message
+ subject = "Welcome to Sahara - Please Activate Your Account"
+
+ # Render the HTML email
+ html_message = render_to_string('welcome_email.html', {
+ 'user': user,
+ 'activation_link': activation_link,
+ })
+
+ # Render the plain-text version of the email
+ plain_message = strip_tags(html_message)
+
+ # Send the email
+ send_mail(
+ subject,
+ plain_message,
+ settings.DEFAULT_FROM_EMAIL,
+ [user.email],
+ html_message=html_message,
+ )
+
+
+
+
+def activate_account(request, token):
+ try:
+ # Decode token and retrieve user
+ user = User.objects.get(email__iexact=user_email_from_token)
+ if user:
+ # Activate user account
+ user.is_active = True
+ user.save()
+ messages.success(request, "Account activated successfully!")
+ return redirect('login') # Redirect to the login page
+ else:
+ messages.error(request, "Invalid activation link.")
+ except Exception as e:
+ messages.error(request, str(e))
+ return redirect('home') # Redirect to homepage in case of error
diff --git a/sahara/media/Screenshot_1.png b/sahara/media/Screenshot_1.png
new file mode 100644
index 0000000..d9c93c6
Binary files /dev/null and b/sahara/media/Screenshot_1.png differ
diff --git a/sahara/media/Screenshot_1_ADxCcNz.png b/sahara/media/Screenshot_1_ADxCcNz.png
new file mode 100644
index 0000000..d9c93c6
Binary files /dev/null and b/sahara/media/Screenshot_1_ADxCcNz.png differ
diff --git a/sahara/media/Screenshot_1_Nr3wRlz.png b/sahara/media/Screenshot_1_Nr3wRlz.png
new file mode 100644
index 0000000..d9c93c6
Binary files /dev/null and b/sahara/media/Screenshot_1_Nr3wRlz.png differ
diff --git a/sahara/media/Screenshot_1_Y0GUvRC.png b/sahara/media/Screenshot_1_Y0GUvRC.png
new file mode 100644
index 0000000..d9c93c6
Binary files /dev/null and b/sahara/media/Screenshot_1_Y0GUvRC.png differ
diff --git a/sahara/media/Screenshot_2025-01-10_182515.png b/sahara/media/Screenshot_2025-01-10_182515.png
new file mode 100644
index 0000000..8e36cba
Binary files /dev/null and b/sahara/media/Screenshot_2025-01-10_182515.png differ
diff --git a/sahara/media/Screenshot_2025-01-10_182515_KdukpRJ.png b/sahara/media/Screenshot_2025-01-10_182515_KdukpRJ.png
new file mode 100644
index 0000000..8e36cba
Binary files /dev/null and b/sahara/media/Screenshot_2025-01-10_182515_KdukpRJ.png differ
diff --git a/sahara/media/uploads/citizenship/Screenshot_1.png b/sahara/media/uploads/citizenship/Screenshot_1.png
new file mode 100644
index 0000000..d9c93c6
Binary files /dev/null and b/sahara/media/uploads/citizenship/Screenshot_1.png differ
diff --git a/sahara/sahara/__pycache__/__init__.cpython-312.pyc b/sahara/sahara/__pycache__/__init__.cpython-312.pyc
index ded5f6c..1f0e050 100644
Binary files a/sahara/sahara/__pycache__/__init__.cpython-312.pyc and b/sahara/sahara/__pycache__/__init__.cpython-312.pyc differ
diff --git a/sahara/sahara/__pycache__/settings.cpython-312.pyc b/sahara/sahara/__pycache__/settings.cpython-312.pyc
index 8b15f7d..d2a2fff 100644
Binary files a/sahara/sahara/__pycache__/settings.cpython-312.pyc and b/sahara/sahara/__pycache__/settings.cpython-312.pyc differ
diff --git a/sahara/sahara/__pycache__/urls.cpython-312.pyc b/sahara/sahara/__pycache__/urls.cpython-312.pyc
index 10b38a5..3031018 100644
Binary files a/sahara/sahara/__pycache__/urls.cpython-312.pyc and b/sahara/sahara/__pycache__/urls.cpython-312.pyc differ
diff --git a/sahara/sahara/__pycache__/wsgi.cpython-312.pyc b/sahara/sahara/__pycache__/wsgi.cpython-312.pyc
index aa72eef..13a12a8 100644
Binary files a/sahara/sahara/__pycache__/wsgi.cpython-312.pyc and b/sahara/sahara/__pycache__/wsgi.cpython-312.pyc differ
diff --git a/sahara/sahara/asgi.py b/sahara/sahara/asgi.py
index 1274027..93f3e37 100644
--- a/sahara/sahara/asgi.py
+++ b/sahara/sahara/asgi.py
@@ -4,7 +4,7 @@ ASGI config for sahara project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
-https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
+https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
"""
import os
diff --git a/sahara/sahara/settings.py b/sahara/sahara/settings.py
index 7fd8178..775d1d4 100644
--- a/sahara/sahara/settings.py
+++ b/sahara/sahara/settings.py
@@ -1,27 +1,32 @@
"""
Django settings for sahara project.
-Generated by 'django-admin startproject' using Django 5.1.4.
+Generated by 'django-admin startproject' using Django 5.0.6.
For more information on this file, see
-https://docs.djangoproject.com/en/5.1/topics/settings/
+https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
-https://docs.djangoproject.com/en/5.1/ref/settings/
+https://docs.djangoproject.com/en/5.0/ref/settings/
"""
from pathlib import Path
import os
+from dotenv import load_dotenv
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
+
+load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
+import os
# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = 'django-insecure-^huq1^)wu+)bo*m#&l_4w6e&oi%iyn+^5%o4kt1zim(!!&an&y'
+SECRET_KEY = 'django-insecure-dw78ln%=0i^uy4zj78lkx=p_98ik3%h@u%wod1va651^1jyy*m'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@@ -38,7 +43,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
- "main",
+ 'main'
]
MIDDLEWARE = [
@@ -71,9 +76,19 @@ TEMPLATES = [
WSGI_APPLICATION = 'sahara.wsgi.application'
+####EMAIL CONF
+
+EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
+EMAIL_HOST = 'smtp.gmail.com'
+EMAIL_USE_TLS = True
+EMAIL_PORT = 587
+EMAIL_HOST_USER = os.environ.get("EMAIL_ADDRESS")
+EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_PASSWORD")
+
+
# Database
-# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
+# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
@@ -84,7 +99,7 @@ DATABASES = {
# Password validation
-# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
+# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
@@ -103,7 +118,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
-# https://docs.djangoproject.com/en/5.1/topics/i18n/
+# https://docs.djangoproject.com/en/5.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
@@ -115,20 +130,20 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
-# https://docs.djangoproject.com/en/5.1/howto/static-files/
+# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
-# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
+# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
+
+AUTH_USER_MODEL = 'main.BaseUser'
+
STATIC_URL = '/static/'
#STATICFILES_DIRS = [BASE_DIR / "static"]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
-
-MEDIA_URL = "/media/"
-MEDIA_ROOT = BASE_DIR / "media"
-
-
+MEDIA_URL = '/media/'
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
\ No newline at end of file
diff --git a/sahara/sahara/urls.py b/sahara/sahara/urls.py
index df9e25a..e33b46c 100644
--- a/sahara/sahara/urls.py
+++ b/sahara/sahara/urls.py
@@ -1,23 +1,12 @@
-"""
-URL configuration for sahara project.
-
-The `urlpatterns` list routes URLs to views. For more information please see:
- https://docs.djangoproject.com/en/5.1/topics/http/urls/
-Examples:
-Function views
- 1. Add an import: from my_app import views
- 2. Add a URL to urlpatterns: path('', views.home, name='home')
-Class-based views
- 1. Add an import: from other_app.views import Home
- 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
-Including another URLconf
- 1. Import the include() function: from django.urls import include, path
- 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
-"""
from django.contrib import admin
-from django.urls import path, include
+from django.urls import path,include
+from django.conf import settings
+from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',include("main.urls"))
]
+
+if settings.DEBUG:
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
diff --git a/sahara/sahara/wsgi.py b/sahara/sahara/wsgi.py
index 3e4f48e..40d30f0 100644
--- a/sahara/sahara/wsgi.py
+++ b/sahara/sahara/wsgi.py
@@ -1,4 +1,14 @@
+"""
+WSGI config for sahara project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
+"""
+
import os
+
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sahara.settings')