Posts

Django REST Framework: The Tool That Made Me Stop Hating APIs

Look, I used to hate building APIs. All that manual JSON serialization, writing the same CRUD views over and over, authentication headaches - it was exhausting. Then I tried Django REST Framework. What Changed? DRF takes all the repetitive stuff and automates it. Here's what sold me: Serializers handle everything. They convert your models to JSON, validate incoming data, and even handle nested relationships. No more manual data munging. ViewSets are magic. Write one ViewSet class and get full CRUD endpoints automatically. Need custom behavior? Just add a method. That's it. Authentication actually works. Token auth, session auth, JWT - pick one, add two lines to your settings, done. A Quick Example This code gets you a complete API: class PostSerializer ( serializers . ModelSerializer ) : class Meta : model = Post fields = '__all__' class PostViewSet ( viewsets . ModelViewSet ) : queryset = Post . objects . all ( ) seri...

A simple tip claculator using python:-

  print ( "Welcome to the tip calculater:-" ) bill = float ( input ( "What is the bill:- $" )) per = int ( input ( "What percentage of tip you want to give?:-" )) up_per = per / 100 tip = bill * up_per total_bill = bill + tip total_amount = round (total_bill, 2 ) print ( f"The total bill is $ { total_amount } " ) split = int ( input ( "How many persons to split the bill:-" )) split_amount = total_bill / split final_amount = round (split_amount, 2 ) print ( f"Each person have to pay $ { final_amount } " )

A Javascript Program for getting the length of the sentence:-

 var sent = prompt("Enter the sentence"); var len = sent.length; alert("The length of the sentence is " + len);

Simple HTML Script for creating a form

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Infopedia</title> </head> <body> <form> <fieldset> <legend>Personal Details</legend> <p> <label> Salutation <br /> <select name="salutation"> <option>--None--</option> <option>Mr.</option> <option>Ms.</option> <option>Mrs.</option> <option>Dr.</option> <option>Prof.</option> </select> </label> </p> <p> <label>First name: <input name="firstName" /></label> </p> <p> ...

write a simple c++ program to print your name

Program:- #include<iostream.h> int main() {   Cout<<"your name";   return 0; }

Write a c program to find area and perimeter of rectangle

 Program:- #include <stdio.h> #include <conio.h> void main() { int l, b; void arearectangle( int , int ); void perimeterrectangle( int , int ); printf( "Enter two values \n" ); scanf( "%d %d" ,&l, &b); arearectangle(l,b); perimeterrectangle(l,b); getch(); } void arearectangle( int l, int b) {   int area;   area=l*b;   printf( "%d is area \n " ,area);   return area; } void perimeterrectangle( int l, int b) {   int perimeter ;   perimeter=2*(l+b);   printf( "%d is perimeter \n" ,perimeter);   return perimeter ; }

Write a c ++ program to delete an element from an array

Program:- #include<stdio.h> void main() {  int a[10],size,num,i,loc;  printf("Operation on 1D array-Delete\n");  printf("Enter size of array \n");  scanf("%d",&size);  printf("Enter elements \n");  for (i=1;i<=size;i++)  {   scanf("%d",&a[i]);  }   printf("Enter location of no. to be deleted \n");   scanf("%d",&loc);  for (i=loc;i<=size-1;i++) {  a[i]=a[i+1]; }  printf("Array element \n");  for(i=1;i<=size-1;i++) {  printf("%d \t",a[i]); } }