Category "python"

How to assign a database model to a user

from django.db import models from datetime import datetime from django.contrib.auth.models import User class News(models.Model): user

ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

i am trying to run tox commands but it shows error ValueError: Unable to find resource t64.exe in package pip._vendor.distlib ERROR: python3.7: could not inst

pandas - repalce a key's value of a dictionary column with another column

In pandas, I have 2 columns, one of which is a dictionary and the other is a numerical column. When the dictionary column is not null, is there a time efficient

Removing values from an 2d array

I have a 2 dimensional numpy array and want to remove all 'false' values. A nested array with different lengths should be created. [['false' 'value1' 'false' 'f

Not Implemented Error in Django Channels Layers

I was following the Django channels tutorial to create a simple chat application. But while trying to check if the channel layer can connect to Redis, I get thi

pyautogui, locate on screen doen't work in linux

I am using linux, and it returns none instead of the co-ordinates. import pyautogui as p a=p.locateCenterOnScreen('like.png',confidence=.5) print(a) Did I di

ORTools CP-SAT Solver. Constraint to require two lists of variables to be drawn from the same set of integers

I have two lists of variables M and T. I would like to create a constraint where the set of unique values between M and T are identical. From the solution varia

django removes "is_staff" permission if I try to login

I have a pretty strange situation within my django project. I have a LoginForm where a user can log into the website. I am using django 3.2.12 with some other l

How to create xpath that matches both conditions present in an element?

Description: I need to create an Xpath that matches both the condition present in the div class = 'item_inside' Explanation: Imagine There are two item_inside c

Implementing a search query inside a filter

I've been trying to implement a search bar inside my application, but I don't know how to query for similar names inside my db. Here is my view.py queryprms

How to validate a file starts with certain perfix format?

I have a list of files with names like this. ["TYBN-220422-257172171.txt", "TYBN-120522-257172174.txt", "TYBN-320422-657172171.txt", "TYBN-220622-237172174.txt

How to check for network security config with Androguard in python script

I have an .apk file and want to check wheter the res/xml/network_security_config.xml [1] trusts user supplied certificates. I read into the androguard docuemnta

ModuleNotFoundError: No module named 'telebot' on heroku

This is the official document https://github.com/python-telegram-bot/python-telegram-bot. How do I using pip install python-telegram-bot --upgrade on heroku. Th

Debug Toolbar not showing

I installed: pip install django-debug-toolbar I have DEBUG=True in my settings I have django.contrib.staticfiles and debug_toolbar in INSTALLED_APPS i have STAT

Try Except is just executing all lines simultaneously (in pyolite kernel with `input()`)

I'm "learning" Python in a course on Coursera, but this lesson doesn't have any explanation and doesn't seem to work at all. As I'm so new, I have no idea what

Why do I need to override the handle_data method in my own class?

Why do I need to override the handle_data() method when it already exists in the library here: https://docs.python.org/3/library/html.parser.html#html.parser.HT

Graph not being displayed on django framework

I want to display a graph using C3 Javascript library which displays future prices of textile raw materials on django framework. When I run the code it does not

Flask Unique SQLAlchemy with Flask-LImiter

I want to make a project with flask where you sign up and sign in and then you can make new posts. I use flask-limiter to prevent users from making new posts. A

WHY tf.keras.layers.Conv2D gives different results at each run

I am trying to reproduce my code from online Jupyter Notebook (COURSERA) to my own local environment (Anaconda 3 Jupyter with CUDA installed) All Codes a

Compare 2 columns in excel using python

Hello I have an excel file (.xlsx) with 2 columns of data I want to compare the rows in column A with column B and output the value of column B in another gener