This is a simple blog application built with Django. It supports categories, blog posts, comments (with threaded replies), and an excerpt feature for posts. The project also uses auto-slug generation for both blog posts and categories.
- Create and manage blog posts with categories.
- Add comments to blog posts, with support for threaded replies.
- Automatically generate slugs for blog posts and categories.
- Show main, recent, and popular blog posts on the homepage.
- Filter blog posts by categories.
- Blog post excerpt support.
- name: The name of the category.
- slug: A unique, auto-generated slug for the category.
- title: The title of the blog post.
- author: The author of the blog post.
- image: Image associated with the post.
- content: Main content of the blog post.
- category: ForeignKey to
Category
. - blog_slug: Auto-generated slug based on the title.
- date: Date when the blog post is published.
- status: Draft or Publish status.
- section: Post section (Recent, Publish, Trending).
- main_post: Boolean to indicate if the post is the main featured post.
- excerpt: Method to generate an excerpt from the content.
- post: ForeignKey to
Blog
. - name: Name of the commenter.
- email: Email of the commenter.
- website: Optional website of the commenter.
- comment: The comment text.
- date: Date and time the comment was posted.
- parent: Optional self-referential ForeignKey for comment replies.
This view renders the homepage with various blog listings:
- Main_post: A featured post.
- Recent: The 5 most recent blog posts.
- Popular: Top 3 trending blog posts.
- Categories: A list of all blog categories with a post count.
This view displays the full details of a blog post, along with the associated comments:
- post: The selected blog post.
- comments: Comments associated with the blog post.
This view displays blog posts filtered by a specific category:
- active_category: The selected category.
- blogs_in_category: Blog posts that belong to the selected category.
This view handles adding a comment to a blog post:
- post: The blog post to which the comment is added.
- name: Name of the commenter.
- email: Email of the commenter.
- website: Optional website of the commenter.
- comment_text: The comment text.
- parent_comment: Optional parent comment for threading.
Displays the main page with various blog listings such as featured posts, recent posts, and categories.
Displays the full blog post with the comment section.
Displays the blog posts filtered by category.
-
Clone the repository:
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the Django migrations:
python manage.py migrate
-
Create a superuser to access the admin panel:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
- Navigate to
http://127.0.0.1:8000/
to view the homepage. - Navigate to
http://127.0.0.1:8000/admin
to manage blog posts, categories, and comments from the Django admin panel.
https://blog-posts-api-rest-api-2.onrender.com/
/admin/ admin creds - username : admin, pass - admin@123