This project is a simple blogging application built with a Django backend and a plain HTML/CSS/JavaScript frontend. It aims to test capabilities in Django, database querying, and basic frontend development.
- User: Use Django's built-in User model.
- Post:
title
: CharFieldcontent
: TextFieldauthor
: ForeignKey to Usercreated_at
: DateTimeFieldupdated_at
: DateTimeField
- Comment:
post
: ForeignKey to Postauthor
: ForeignKey to Usercontent
: TextFieldcreated_at
: DateTimeField
- User Registration: Endpoint to create a new user.
- Authentication: Use Django Rest Framework's token authentication.
- Create Post: Authenticated users can create a post.
- List Posts: List all posts.
- Most Commented Posts: An endpoint that returns the top 5 most commented blog posts.
- Retrieve Post: Get details of a specific post.
- Update Post: Authenticated users can update their own posts.
- Delete Post: Authenticated users can delete their own posts.
- Create Comment: Authenticated users can comment on a post.
- List Comments: List all comments for a specific post.
- Retrieve Comment: Get details of a specific comment.
- Update Comment: Authenticated users can update their own comments.
- Delete Comment: Authenticated users can delete their own comments.
- Ensure users cannot edit or delete posts or comments they do not own.
- Ensure all fields are properly validated (e.g., title should not be empty, content should not be too short).
- I'm write unit tests for the models and views.
- Include a
README.md
with instructions on setting up and running the project. - API documentatiin Postman Postman Collection.
- Home Page: Display a list of all blog posts with titles and excerpts.
- Most Commented Posts Page: Display the top 5 most commented posts.
- Post Detail Page: Display the full content of a single post, along with its comments.
- Login/Register Page: Allow users to register and log in.
- Create/Edit Post Page: Form to create a new post or edit an existing one.
- User Authentication: Allow users to log in and register. Use tokens for authenticated API requests.
- Create/Edit/Delete Posts: Allow authenticated users to create, edit, and delete their posts.
- Create/Edit/Delete Comments: Allow authenticated users to comment on posts and manage their comments.
- Use plain HTML, CSS, and JavaScript (I'm use Vue.js to simplify implementation).
-
Clone the repository:
git clone git@github.com:yaacovdev/blog_app.git cd blog_app
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r backend/requirements.txt
-
Apply migrations:
python backend/manage.py migrate
-
Run the development server:
python backend/manage.py runserver
-
CreateSuperUser:
python backend/manage.py createsuperuser
-
Frontend:
- Open
frontend/index.html
in a web browser to view the frontend.
- Open
To run the tests, execute:
cd backend
python manage.py test