October 22, 2024
Chicago 12, Melborne City, USA
python

Simple JWT TokenRefreshView: response has two types

I’m having trouble accessing the data attribute on a Response object in Django Rest Framework after refreshing the access token. factory = APIRequestFactory() new_request = factory.post( "/api/token/refresh/", {"refresh": refresh_token}, format="json", ) new_request.META["CONTENT_TYPE"] = "application/json" refresh_view = TokenRefreshView.as_view() refresh_response = refresh_view(new_request) print(type(refresh_response)) refresh_response.data["message"] = "Token refresh successful" When I run this code, the print statement correctly

Read More
python

How do I plot matrixes of data in 3d using Python?

I am working with OCT scans and I have 3d matrixes of data, the background has the value 0.0 and the rest is aligned in the middle. How my current data looks in 2d plotting This image is an example of what I currently have, with the following shape/format Tensor [25, 496, 512] How do

Read More
python

SQLAlchemy hangs when sending ALTER TABLE

I’m trying to add a column to a PostgreSQL table with SQLAlchemy. I read on a couple threads that the simplest way to do this is to send plain SQL rather than modifying the Table object. My query is really basic: import sqlalchemy engine = create_engine("postgresql://user@host:port/db") query = sqlalchemy.text("alter table schema.table add column if not

Read More
python

How do I make caves randomly generate in pygame?

My game is supposed to be like Minecraft using pygame, but 2D. I do not know how to generate caves, and other questions I looked at didn’t really work, like this: Perlin worms for 2D cave generation. That did not explain how to, and I am trying to find out. I heard of perlin noise,

Read More