Skip to main content

Posts

Why the User data are not updated? in Django?

I have a Model called UserAccount, I have tried several ways to update the data for an existing user, it responds that changes are successful without any error but still nothing is reflecting in Database Here is the Model class UserAccount(AbstractBaseUser,PermissionsMixin): first_name = models.CharField( max_length=100) last_name = models.CharField(max_length=100) email = models.EmailField(_("email"),validators=[EmailValidator()],unique=True) date_added = models.DateTimeField(auto_now_add=True) phone = models.CharField(max_length=20, validators=[RegexValidator(r'^\d{12}$', 'Enter a valid phone number.')]) profile_picture = models.ImageField(upload_to='media/users_photos/%Y/%m',null=True,blank=True) employee_id = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(999)], null=True,blank=True) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) last_l...

Counting the points below a coordinate

I have the following problem, for which the solution I use at the moment is too slow. Instance: a numpy array b of shape (B,2) , a sorted numpy array x of shape (X) , and a sorted numpy array y of shape (Y) . Note that x = np.unique(b[:,0]) and y = np.unique(b[:,1]) , if that makes a difference for the problem. Task: Build the (X,Y) -array H such that H[i,j] is the number of rows in b whose first entry is less than x[i] and whose second entry is less than y[j] . The following example code solves this: import numpy as np b = np.random.random((2000,2)) x = np.unique(b[:,0]) y = np.unique(b[:,1]) H = np.count_nonzero( np.logical_and( b[:,0,None,None] <= x[None,:,None], b[:,1,None,None] <= y[None,None,:] ), axis=0 ) but this gets quite slow if b and thus x and y have a few thousand entries. How can I do this more efficiently? source https://stackoverflow.com/questions/77044480/counting-the-points-below-a-coordinate

extract matched data from array

I am not able to find a best way to do it so i am asking here. I have an array of object let x = [{name: "Apple", message: {data: {}}, {name: "dell", message: {data: {}}, {name: "samsung", message: {data: {}} ]; now i have list of name that i need to check and if it is found in the array find the first one like let y = {laptop: ["Apple", "HP" ], phone: ["samsung", "Motorolla" ] What i need result = { laptop: { name: "Apple", message: { data: {} }, phone: { name: "samsung", message: { data: {} } } } this variable can be any data structure, right now best i can do is O(n ^2) and this check need to be done more than 40 times a second so i want to be done in efficient way. Is there any way i can do this in best possible way. Via Active questions tagged javascript - Stack Overflow https:...

SSR for MUI createTheme with NextJs

Longtime C# dev, just starting nextjs for a client. I'm using MUI, and basically have a day of work in, so my project is pretty small. I have a decent handle on how SSR works conceptually, but implementation is throwing me for a weird loop. Here's my layout.js: <!-- language:javascript --> import "./globals.css"; import { Drawer, ListItemButton, ListItemIcon, ListItemText, List, AppBar, Toolbar, Typography, Box, } from "@mui/material"; import AssessmentIcon from "@mui/icons-material/Assessment"; import AddIcon from "@mui/icons-material/Add"; import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted"; import zIndex from "@mui/material/styles/zIndex"; import { theme } from "./theme"; import { ThemeProvider } from "@mui/material/styles"; const navItems = [ { name: "Create New", icon: <AddIcon />, url: "todo" }, { name: "Vie...

Navbar with pop menu [closed]

Good day, I need a little help with my navbar When I shrink-site it and press the hamburger menu icon the images from the slider block the view of a menu I can not press any links any advice to fix it I have put a dummy text for representation. `https://codepen.io/Sem-Lion/pen/LYMbWLK` Via Active questions tagged javascript - Stack Overflow https://ift.tt/Vd7yleC

How to hide/unhide hidden node and update the connected edges in graph on click of connected edges

Graph-1 image of Graph-1 click to preview In the above graph there are 2 types of node , "Hidden Node" and "Non Hidden Node" which is connected to another node. The connection is call "edges" . "node" and "edges" data look likes : let nodes = [ { id: 1, node_name: "Node-1", is_hiddenable: false, hidden: false }, { id: 2, node_name: "Node-2", is_hiddenable: false, hidden: false }, { id: 3, node_name: "Node-3", is_hiddenable: true, hidden: false }, { id: 4, node_name: "Node-4", is_hiddenable: true, hidden: false }, { id: 5, node_name: "Node-5", is_hiddenable: true, hidden: false }, { id: 6, node_name: "Node-6", is_hiddenable: false, hidden: false }, { id: 7, node_name: "Node-7", is_hiddenable: false, hidden: false }, { id: 8, node_name: "Node-8", is_hiddenable: true, hidden: false }, { id: 9, node_name: "Node-9", is_hidden...

Cannot access ID from method in kivy

I'm trying to create a card in which I can place a scroll view on that appears on the viewdecks screen after the user has logged in to do this I called the ViewDecks.ShowDecks() method from inside of the login class, I think this is creating a problem as when I run the code I get this error: deck_list = self.ids.deck_scroll File "kivy\properties.pyx", line 964, in kivy.properties.ObservableDict. getattr AttributeError: 'super' object has no attribute ' getattr '.I'm not sure how to fix this. from kivy.lang import Builder from kivymd.app import MDApp from kivy.uix.screenmanager import ScreenManager, Screen import mysql.connector from kivymd.uix.dialog import MDDialog from kivymd.uix.button import MDRaisedButton from kivy.uix.scrollview import ScrollView from kivymd.uix.card import MDCard from kivymd.uix.label import MDLabel class Login(Screen): def sign(self): if self.ids.user.text == "" or self.ids.passw.text == "" or...