diff --git a/templates/accounts/login.html b/accounts/templates/login.html
similarity index 100%
rename from templates/accounts/login.html
rename to accounts/templates/login.html
diff --git a/accounts/templates/logout.html b/accounts/templates/logout.html
new file mode 100644
index 0000000..e888b36
--- /dev/null
+++ b/accounts/templates/logout.html
@@ -0,0 +1,8 @@
+{% extends 'base.html' %}
+
+{% block title %}Logout{% endblock %}
+
+{% block content %}
+
You have been logged out.
+Return to Home
+{% endblock %}
diff --git a/accounts/templates/profile.html b/accounts/templates/profile.html
new file mode 100644
index 0000000..d303b9a
--- /dev/null
+++ b/accounts/templates/profile.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+ User Profile
+ {% load static %}
+
+
+
+
+ {{ user.username }}'s Profile
+
+
+ Email: {{ user.email }}
+ First Name: {{ user.first_name }}
+ Last Name: {{ user.last_name }}
+
+
+
diff --git a/templates/accounts/signup.html b/accounts/templates/signup.html
similarity index 100%
rename from templates/accounts/signup.html
rename to accounts/templates/signup.html
diff --git a/templates/accounts/user_create.html b/accounts/templates/user_create.html
similarity index 100%
rename from templates/accounts/user_create.html
rename to accounts/templates/user_create.html
diff --git a/templates/accounts/user_delete.html b/accounts/templates/user_delete.html
similarity index 100%
rename from templates/accounts/user_delete.html
rename to accounts/templates/user_delete.html
diff --git a/templates/accounts/user_detail.html b/accounts/templates/user_detail.html
similarity index 100%
rename from templates/accounts/user_detail.html
rename to accounts/templates/user_detail.html
diff --git a/templates/accounts/user_list.html b/accounts/templates/user_list.html
similarity index 100%
rename from templates/accounts/user_list.html
rename to accounts/templates/user_list.html
diff --git a/templates/accounts/user_update.html b/accounts/templates/user_update.html
similarity index 100%
rename from templates/accounts/user_update.html
rename to accounts/templates/user_update.html
diff --git a/accounts/views.py b/accounts/views.py
index 1b904ca..bce5152 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -13,13 +13,19 @@
from .models import CustomUser, Follow, Post
from .forms import CustomUserCreationForm, CustomUserChangeForm
from django.shortcuts import render
-from django.shortcuts import render
from django.contrib.auth.forms import AuthenticationForm
+from django.contrib.auth import logout
+
def home(request):
return render(request, 'home.html')
+
+def accounts_home(request):
+ return redirect('login') # Redirects to the login page
+
+
def home(request):
return render(request, 'home.html')
@@ -71,7 +77,7 @@ def user_profile(request, user_id):
'followers': followers,
'following': following,
}
- return render(request, 'accounts/profile.html', context)
+ return render(request, 'accounts/profile.html', {'user': user})
def login_view(request):
form = AuthenticationForm(data=request.POST or None)
@@ -80,14 +86,16 @@ def login_view(request):
login(request, user)
next_url = request.GET('next', 'home')
return redirect('home')
-
return render(request, 'login.html', {'form': form})
-def logout_view(request):
- if request.method == 'POST':
- logout(request)
+def logout_view(request):
+ if request.method == 'POST':
+ logout(request)
return redirect('home')
+ else:
+ return redirect('home') # Redirect to home if not POST request
+
def signup(request):
diff --git a/templates/notifications/notifications_list.html b/notifications/templates/notifications_list.html
similarity index 100%
rename from templates/notifications/notifications_list.html
rename to notifications/templates/notifications_list.html
diff --git a/templates/posts/feed.html b/posts/templates/feed.html
similarity index 100%
rename from templates/posts/feed.html
rename to posts/templates/feed.html
diff --git a/templates/posts/post_create.html b/posts/templates/post_create.html
similarity index 100%
rename from templates/posts/post_create.html
rename to posts/templates/post_create.html
diff --git a/templates/posts/post_detail.html b/posts/templates/post_detail.html
similarity index 100%
rename from templates/posts/post_detail.html
rename to posts/templates/post_detail.html
diff --git a/templates/posts/post_list.html b/posts/templates/post_list.html
similarity index 100%
rename from templates/posts/post_list.html
rename to posts/templates/post_list.html
diff --git a/templates/posts/post_update.html b/posts/templates/post_update.html
similarity index 100%
rename from templates/posts/post_update.html
rename to posts/templates/post_update.html
diff --git a/social_media_api/__pycache__/settings.cpython-313.pyc b/social_media_api/__pycache__/settings.cpython-313.pyc
index 06b003d..1172f37 100644
Binary files a/social_media_api/__pycache__/settings.cpython-313.pyc and b/social_media_api/__pycache__/settings.cpython-313.pyc differ
diff --git a/social_media_api/settings.py b/social_media_api/settings.py
index 8aa0dc0..de4d673 100644
--- a/social_media_api/settings.py
+++ b/social_media_api/settings.py
@@ -31,7 +31,11 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
-ALLOWED_HOSTS = ['social-media-api-a5m3.onrender.com', '127.0.0.1:8000']
+ALLOWED_HOSTS = [
+ 'localhost',
+ '127.0.0.1',
+ 'social-media-api-a5m3.onrender.com',
+]
# Application definition
@@ -122,8 +126,8 @@
# settings.py
-DATABASES = {
- 'default': dj_database_url.config(conn_max_age=600)
+DATABASES = {
+ 'default': dj_database_url.config(default=config('DATABASE_URL'))
}
diff --git a/social_media_api/urls.py b/social_media_api/urls.py
index 1084b9c..29e19f0 100644
--- a/social_media_api/urls.py
+++ b/social_media_api/urls.py
@@ -25,8 +25,7 @@
path('api/accounts/', include('accounts.urls')),
path('api/notifications/', include('notifications.urls')),
path('api/posts/', include('posts.urls')),
- path('', home_view, name='home'),
- path('accounts', include('allauth.urls'))
+ path('accounts', include('allauth.urls')),
]
if settings.DEBUG:
diff --git a/staticfiles/home/styles.css b/staticfiles/home/styles.css
new file mode 100644
index 0000000..690457d
--- /dev/null
+++ b/staticfiles/home/styles.css
@@ -0,0 +1,32 @@
+body {
+ font-family: Arial, sans-serif;
+ margin: 0;
+ padding: 0;
+ background-color: #f9f9f9;
+}
+
+header {
+ background-color: #333;
+ color: #fff;
+ padding: 1em;
+ text-align: center;
+}
+
+h1 {
+ color: #333;
+}
+
+nav ul {
+ list-style: none;
+ padding: 0;
+}
+
+nav li {
+ display: inline;
+ margin-right: 1em;
+}
+
+nav a {
+ color: #fff;
+ text-decoration: none;
+}
\ No newline at end of file
diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html
deleted file mode 100644
index f999679..0000000
--- a/templates/accounts/profile.html
+++ /dev/null
@@ -1,39 +0,0 @@
-{% extends 'base.html' %}
-
-{% block content %}
-{{ user.username }}
-
-{{ user.bio }}
-
-Posts
-
- {% for post in posts %}
- - {{ post.content }}
- {% endfor %}
-
-
-Followers
-
- {% for follower in followers %}
- - {{ follower.follower.username }}
- {% endfor %}
-
-
-Following
-
- {% for following in following %}
- - {{ following.following.username }}
- {% endfor %}
-
-
-{% if user != request.user %}
-
-
-{% endif %}
-{% endblock %}
diff --git a/templates/base.html b/templates/base.html
index f28e94d..b12cf15 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -16,9 +16,13 @@
Accounts API
Notifications API
Posts API
- Accounts
{% if user.is_authenticated %}
- Sign Out
+
+
+
{% else %}
Sign Up
Sign In
@@ -40,9 +44,12 @@
Accounts API
Notifications API
Posts API
- Accounts
{% if user.is_authenticated %}
- Sign Out
+
+
{% else %}
Sign Up
Sign In