Posts

Dynamically Change width and height of Div using CSS and React

         const [ size_w , setSize_w ] = useState ( '210mm' );      const [ size_h , setSize_h ] = useState ( '297mm' ); /////////////   const changelayout = () => {             const temph = size_h === '210mm' ? '297mm' : '210mm' ;             const tempw = size_w === '297mm' ? '210mm' : '297mm'             setSize_h ( temph );             setSize_w ( tempw );     } //////////////////// < button className = "bg-blue-500 text-white px-4 py-2 mr-2 rounded" onClick = { changelayout } > Change Layout </ button > ////////////// < div ref = { contentToPrint } id = "printable-content" style = { { width : size_w , height : size_h } } className = "print-content p-4 bg-white" > </div>

Convert Object to Array in JavaScript

 https://www.linkedin.com/pulse/7-ways-convert-objects-array-javascript-awais-al-waisy

Manage Dynamically Created Component in React

Dailywork.js ////////////////////////////////// import React ,{useState, useEffect} from "react"; import axios from "axios"; import Dailyworkdetails from './Dailyworkdetails' import Reacttoexcel from "./Reactttoexcel"; import dayjs from "dayjs"; function Dailywork(){     const [holyday,setHolyday]=useState([])     const [batchinfo,setBatchinfo]=useState([])     const [coursehinfo,setCourseinfo]=useState([])     const [filterbatchDetails,setFilterbatchDetails]=useState([])     const [selectedCourse, setSelectedCourse] = useState("");     const [selectedBatch, setSelectedBatch] = useState("");     const [tempbatch,setTempbatch]=useState()     useEffect(()=>{         axios.get('http://127.0.0.1:8000/batchlist/')         .then((res)=>{setBatchinfo(res.data);})         .catch((error) => {             console.error("...

Convert List to string in React

 1.  const myList = [ 'apple' , 'banana' , 'orange' ]; const myString = myList. join ( ', ' ); // Join array elements with ', ' console . log (myString); // Output: "apple, banana, orange" 2. const myList = [ 'apple' , 'banana' , 'orange' ]; const myString = myList. toString (); console . log (myString); // Output: "apple,banana,orange"

Duration between two time in react||JavasScript

    if ( startTime . ampm === endTime . ampm ){           if(startTime.hr>endTime.hr||((startTime.hr===endTime.hr)&&startTime.min>endTime.min))              {               alert("Select Proper Value")              }              else{               var h1=endTime.hr-startTime.hr               if(startTime.hr===endTime.hr){                 var m1=parseInt(endTime.min-startTime.min)               }               else{                 var m1=parseInt(endTime.min)+parseInt(60-startTime.min)               }              ...

Iterate React Component based on an integer value| convert an integer to array

   batchtempinfo. numberoftimeframe > 0 && Array . from ({ length : batchtempinfo. numberoftimeframe }). map ( ( _, index ) => ( < Timeslote key = {index} timeslote = {batchtempinfo.numberoftimeframe} /> )) ///////////////////////////   Array . from ({ length : timeframe }). forEach (( _ , index ) => {                 let t = detailstrainer ( item [ `s ${ index + 1 } trainer` ]);                 console . log ( "trainer details " , t );                 temp . push ( t );             });

How to delete all existing record in django model using terminal

  Using Django shell: Open a terminal. Navigate to your Django project directory. Run the Django shell. python manage.py shell Execute the following commands in the Django shell to delete all records from a specific model: python # Import the model from your_app.models import YourModel # Delete all records YourModel.objects. all ().delete() Make sure to replace YourModel with the name of the model you want to delete records from and your_app with the name of your Django app where the model is defined. Example: Let's say you have a model named Employee in an app named company : python # company/models.py from django.db import models class Employee (models.Model): name = models.CharField(max_length= 100 ) department = models.CharField(max_length= 100 ) # Other fields... To delete all records from the Employee model: python from company.models import Employee Employee.objects. all ().delete()