Skip to content

KristopherPoston/Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# 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
  1. Create a virtual environment (optional but recommended):

    python3 -m venv venv
  2. Activate the virtual environment:

    • For MacOS/Linux:
      source venv/bin/activate
    • For Windows:
      venv\Scripts\activate
  3. Install required dependencies:

    pip install -r requirements.txt
  4. Apply database migrations:

    python manage.py migrate
  5. Create a superuser to access the Django admin (optional but recommended for testing):

    python manage.py createsuperuser
  6. Run the development server:

    python manage.py runserver

    The app should be accessible at http://127.0.0.1:8000.

App Overview

URL Routes

  • /: 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.

Models

User

The custom user model includes basic user attributes and relations for following and followers.

Post

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.

Relationships:

  • A user can follow many users and be followed by others.
  • Posts can be liked or disliked by users.

Views

  • 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.

Development

Running Tests

To run tests:

  1. Ensure you have applied the database migrations.

  2. Run:

    python manage.py test

Debugging

For debugging, ensure the DEBUG setting in settings.py is set to True. Use the Django Debug Toolbar for enhanced debugging.

Contributing

If you'd like to contribute to this project, feel free to fork the repository and submit a pull request.

  1. Fork this repository.
  2. Create a new branch (git checkout -b feature-name).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-name).
  5. Create a new pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors