I have two models, Account model & Thread model: If I have already created a thread that is ForeignKey to the Account model, I am not able to change the username of the Account model, returning the error FOREIGN KEY constraint failed. I guess the existing Thread model require a username to point to. Is there way to create a
Category: Questions
‘pdflatex’ not found in subprocess within a bundled PyInstaller APP
I am attempting to create a macOS standalone app from a PyQt5 GUI using PyInstaller. All works apart from automatically generating a PDF from a TEX file using the pdflatex module (in conjunction with Pylatex). Both the pylatex and pdflatex modules require calling the subprocess module, which is done as following: Where args=[‘pdflatex’, ‘-output-directory=/Users/Desktop’, ‘-interaction-mode=batchmode’, ‘-jobname=test’] This however does not
Python, Tkinter – Enable/Disable buttons only when a radio button is selected
So here’s my code What I’m trying to do is have the buttons enabled when the radio buttons are selected. Here’s what I tried. I believe this only sets it initially, and when I select a radio button or change it, it doesn’t update. I think I can use command inside the buttons but don’t understand how to go about
Incorrect password string gets entered by send_keys in selenium python
Somehow send_keys enters repeat password or string other than mentioned password leading login failure. Tried adding explicit wait(), driver.clear() but does not work. Here is a sample code in Python – Approach 1 – Here instead of “xyz” probably “xyzxyzxyzx” string gets added to the password field(cannot decode as password gets masked). Please suggest. Approach 2 – Also, another try
Mongo db array of images change schema
I have an array of images in mongodb and I am trying to change the schema of the array. Right now the images are stored like bellow And the final output I want is like bellow. How can I do this in mongosh? Is it easier to do this as a Python Array and then import back to mongodb? Thank
How to have an incomplete block in Python without error?
This is my code which logically throws error that needs indentation: elif platform == ‘win32’: IndentationError: expected an indented block I need Python to check if OS is whether Linux or Windows, open the file in home of that user and do the same code (in this case for loop) after detecting the OS. Is there a way to avoid
How to use patch.object() correctly
I’m trying to get my head around Mock and patch(), but I’m stuck on a somewhat simple example. Say I have the following function in main.py, which tests if it’s a weekday or not. I want to run my test with two possible outcomes: either False if I mock Saturday or Sunday or True if it’s a weekday. Now, I’m
Construct a graph of nodes using adjacency list in Python
I have a Node class as below I am trying to construct a Graph using an adjacency list as below: In the above adjacency list that is indexed from 1, the index is the Node value i.e. Node.val and the list at that index are the neighbors i.e. Node.neighbors For e.g., for index 1: For index 2: and so on
for loop with zip in python
I want to use zip to iterate to existing Lists. I did that with the code below. Currently the output is just Name –> Name. How do I use the new creates list or if that’s not possible the other lists to print following sentence: “#NAME is #AGE years old, and they can be called at #NUMBER”. Is it possible
Dash chart does not display default dropdown value selection upon page load and refresh
I’m just getting to grips with Dash but am coming across a problem I can’t resolve. I am trying to pass a default dropdown value to a line chart upon page load, but even though the value is present in the dropdown menu it doesn’t render in the chart: As soon as I select another country (region) though, the chart