# Social Network Web Application
This is a Django-based social network web application where users can register, log in, post content, and interact with others through liking, disliking, following, and editing posts. It offers basic functionality like viewing posts, user profiles, and following others.
## Features
- User Registration & Login
- Create, Edit, and View Posts
- Follow/Unfollow Users
- Like and Dislike Posts
- Paginated Posts Display
- User Profile Pages
## Installation Instructions
### Prerequisites
- Python 3.x
- Django 3.x (or compatible version)
- SQLite (or another database for production)
### Steps to Install
1. Clone the repository:
```bash
git clone https://github.com/your-username/your-repository-name.git
cd your-repository-name-
Create a virtual environment (optional but recommended):
python3 -m venv venv
-
Activate the virtual environment:
- For MacOS/Linux:
source venv/bin/activate - For Windows:
venv\Scripts\activate
- For MacOS/Linux:
-
Install required dependencies:
pip install -r requirements.txt
-
Apply database migrations:
python manage.py migrate
-
Create a superuser to access the Django admin (optional but recommended for testing):
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
The app should be accessible at
http://127.0.0.1:8000.
/: The home page, displaying the network overview./login: The login page for existing users./logout: Logs the user out and redirects to the home page./register: Allows users to register./createPostViewPage: A page to create a new post./createPostModel: Processes the form submission to create a new post./allPosts: Displays all posts with pagination (4 posts per page)./profileView: Displays the profile page of a user, including their posts, followers, and following./followingView: Shows posts from users the current user follows./incrementLikes: Endpoint for liking a post./incrementDislikes: Endpoint for disliking a post./followUser: Endpoint to follow or unfollow a user./editPost: Endpoint to edit a user's post.
The custom user model includes basic user attributes and relations for following and followers.
Represents a user's post, including fields like:
user: The user who created the post.body: The content of the post.timestamp: The time the post was created.likes: Count of likes.dislikes: Count of dislikes.
- A user can follow many users and be followed by others.
- Posts can be liked or disliked by users.
index: Renders the homepage.login_view: Handles user login and authentication.logout_view: Logs out the user and redirects to the home page.createPostViewPage: Renders the page to create a new post.createPostModel: Processes post creation.allPosts: Displays a list of all posts, with pagination support.register: Handles user registration.profileView: Displays a user's profile with their posts and follows.followingView: Displays posts from users the logged-in user is following.incrementLikes: Increases the like count for a post.incrementDislikes: Increases the dislike count for a post.followUser: Follows or unfollows a user.
To run tests:
-
Ensure you have applied the database migrations.
-
Run:
python manage.py test
For debugging, ensure the DEBUG setting in settings.py is set to True. Use the Django Debug Toolbar for enhanced debugging.
If you'd like to contribute to this project, feel free to fork the repository and submit a pull request.
- Fork this repository.
- Create a new branch (
git checkout -b feature-name). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-name). - Create a new pull request.
This project is licensed under the MIT License - see the LICENSE file for details.