Code Monkey home page Code Monkey logo

-blog-api's Introduction

About The Project

-Blog-API-



A blog API in Django is an API that allows developers to interact with a blog's data, such as posts, comments, and categories, using Django as the backend. To create a blog API in Django, you can use the Django Rest Framework, which is a powerful tool for building APIs in Django. This framework allows you to create views, serializers, and routers that handle the data and interactions with the API. The views handle the logic of the API and how it responds to requests, the serializers handle the data and how it is formatted when sent and received, and the routers handle the URL patterns and routing for the API. Once the API is developed, it can be integrated into a web or mobile application to allow users to interact with the blog data

  • Install DRF by adding it to your project's requirements.txt file or by running pip install djangorestframework..
  • To add JSON Web Token (JWT) authentication to a Django REST Framework (DRF) API, you can use the djangorestframework_simplejwt package. Here is a general guide to adding JWT authentication to your API: -Install the djangorestframework_simplejwt package by adding it to your project's requirements.txt file or by running pip install djangorestframework_simplejwt.
  • Add 'rest_framework_simplejwt' to your INSTALLED_APPS in your settings.py file.

Main Topics

  • Creating serializers
  • Setting URLs
  • Setting up JWt authentication in Django rest framework
  • Creating models for the Blog app
  • Serializer for a Blog application
  • Post method for a Blog application
  • Get method for Blog Application
  • Patch method for a blog application
  • Delete method for Blog Application
  • Adding pagination to Blogs

Built With

Python

Django DjangoREST

PostgreSQL Github Pages

Visual Studio Code


Running this project

This is a sample for Django Project. To get this project up and running you should start by having Python installed on your computer. It's advised you create a virtual environment to store your projects dependencies separately. You can install virtualenv with

pip install virtualenv

Clone or download this repository and open it in your editor of choice. In a terminal (mac/linux) or windows terminal, run the following command in the base directory of this project

virtualenv venv

That will create a new folder env in your project directory. Next activate it with this command on mac/linux:

source venv/bin/active

Then install the project dependencies with

pip install -r requirements.txt

Create a Project

python manage.py startproject blog

Create apps

python manage.py startapp account
python manage.py startapp home

Create Folder

  • API (Create url.py) -> easy acess url

Create apps

python manage.py startapp account
python manage.py startapp home

Create file serializer.py

  • In Create apps
from rest_framework import serializers

account app create

  • Register
  • Login

Create JWT

  • Documtation Link
https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html

Apply migrations and create your database

python manage.py migrate

Create a user with manage.py

python manage.py createsuperuser

Now you can run the project with this command

python manage.py runserver

Django rest framework is one of the most popular web framework for building rest APIs in Django. We will be seeing how we can create CRUD APIs in the Django rest framework. Also, we will be seeing how we can implement JWT authentication, pagination and search functionality in this application. You will be learning some of the core concepts of the Django rest framework like serializer, APIView, response, and status code in the Django rest framework.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.