Skip to main content

Posts

What is the best way to filter and sort data in react and DRF

I have a back-end built using Django Rest Framework and front-end served using React. I'm having a Filter component and Sort By component. I receive the products data as a json from back-end. I want to be able to filter by few fields such as category, brand, price etc and sort based on fields as well like ascending category, descending price etc . Basically i'd want my url to look like this /products?category=a&category=b&brand=c&sort=category_desc My question is What is the best way to filter data i.e should i send data to back-end to filter using django-filters or filter using a javascript array.filter() ? Should i sort using django-filter's OrderFilter or custom javascript's array.sort() How to synchronise the query params in front-end with both filters and sortby conditions. I'm new to this, so if there is any blog post or document i can go through, that would be really helpful too along with your inputs. Thanks in advance! Via Active

How display a PDF file in the same view on the right

I have a view where I have a TreeList that when clicking on the nodes I would like to display PDF files on the same view. For this every time I click on the nodes it calls a controller sent as a parameter an ID and this returns the file currently works but opens it in another tab. What I want to do is somehow display in another panel to the right of the TreeList the documents in the view. I leave an image for better understanding and the code below Currently the PDF opens in another tab I want to display the document on the right panel of the screen View @model ViewModels.Home.MRecords <script> > This function when clicking on the nodes call Controller and return PDF document. function onNodeClick(s, e) { window.location.href = '@Url.Action("GetAttachments", "Home")' + "?Id=" + e.nodeKey } //Here I call to the actually Partial view where I have the TreeList. @Html.Partial("_TreeListPartial", Model)

KeyError: 'SQLALCHEMY_TRACK_MODIFICATIONS' , I keep getting this error even after trying the solution to previous posts

I was trying to make a dashboard that would have an API for retrieving data from the database then app.py would have all the code for analytics and then I would have designed the dashboard. The problem is I was following this tutorial for APIs and everything was going well and then I got this error, I referred to the answers to similar errors in StackOverflow but couldn't make much sense. http://192.168.224.111:5000/dataapi/jsondata This is the address which when loaded is causing this error Here is the code:- dataapi.py from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_marshmallow import Marshmallow from flask_restful import Resource, Api dataapi = Flask(__name__) api = Api(dataapi) dataapi.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///jsondata.db' dataapi.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(dataapi) ma = Marshmallow(dataapi) class Data(db.Model): id = db.Column(db

What causes the dallied hiding of the load more button in this Angular app?

I have been working on an app with Angular 2+. I am currently working on loading more items at the click of a "Load more" button. In users.component.ts I have: import { Component } from '@angular/core'; import { Employee } from '../../models/empModel'; @Component({ selector: 'app-users', templateUrl: './users.component.html', styleUrls: ['./users.component.css'], }) export class UsersComponent { public itemsNumber: number = 4; public more: Boolean = true; public empsArray: Employee[] = [ { empno: 10256, ename: 'Scott', job: 'Manager', deptno: 10 }, { empno: 10257, ename: 'Smith', job: 'Lead', deptno: 20 }, { empno: 10258, ename: 'Sandy', job: 'Programmer', deptno: 30 }, { empno: 10259, ename: 'Sam', job: 'Tester', deptno: 40 }, { empno: 10260, ename: 'Jane', job: 'Manager', deptno: 10 }, { empno: 10261, ename: '

Firebase functions not executing

I have a firebase project using node.js and I have a form that logs in and can sign up new users. I have recently wanted to make a welcome function that send a welcome email to the user when they sign up and when running the function no email is sent but no errors are thrown either. I expected an email to be sent to the email, nathantolley2008@gmail.com, but no email is sent. I have a functions folder in my root directory and this is what the structure of that folder looks like: The code for the index.js file is as follows: const functions = require("firebase-functions"); const { sendEmail } = require('./sendEmail'); // Export the functions exports.sendEmail = functions.auth.user().onCreate((user) => { sendEmail(user); }); The config.js file: const functions = require('firebase-functions'); const admin = require('firebase-admin'); const serviceAccount = require('./course-curve-firebase-adminsdk-ae6ht-411a2a0ae9.json'); admin.initia

How to display select options depend on another select in php?

In a database I have a table 'courses' and each course has number of sections(1,2,3,...) all stored in table 'sections'. I want to make a form where the user selects a course from the available courses, then displays another selection input with the course's sections to choose from. Here's what I've done, it worked but when I click 'next' after selecting the course and the section selection shows up, the name of the course selected will not show up. Does anyone know an easier way to do this using PHP or javascript? Can you show me how please. <form id="form2" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return checkData();"> <label for="ccode">Select Course:</label> <select name='ccode' required> <option selected="true" disabled="disabled" value="">Select</option>"

scraping a URL address for reviews

So I need to extract the reviews from the URL of a product on this site, more specifically the username, date, text, and score. However, I have some issues with it because I keep getting an error: failed to retrieve reviews for page 1. Error: "Connection broken: InvalidChunkLength(got length b'', 0 bytes read)"; "InvalidChunkLength(got length b'', 0 bytes read)"; I tried adding a time delay but it still doesn't work. How can I modify this? import json import requests from bs4 import BeautifulSoup url = "https://www.emag.ro/covor-antiderapant-negru-poliester-80-x-300-cm-c027-80x300/pd/DBY5YJMBM/?ref=sponsored_products_fill_a_b_5_3&provider=rec&recid=rec_73_c449bb3e50b63cc8f6da4a42a31af359f6cbfb3c547bc5748cb6d45501a29685_1684315709&scenario_ID=73&aid=034a897a-956c-11ed-9004-0ab644dfda7c&oid=89847310" review_url = "https://www.emag.ro/review/get-review-listing-page?id={product_id}&page={page}" headers =