Unable handle the Csrf-Token for GET request in Django
In Django framework, When it was a POST request, if you modify the Cookie CSRF token, its throws the 403 error. But when it was a GET request, I tried to modify the Cookie CSRF-token, and it returned a 200 OK status code. I also want to validate the token for the GET request.
I mentioned {% csrf_token %} in the Forms templates , but it could not handle this issue for GET request. I tried @csrf_protect in the view , it did not helpful.
import pandas as pd
File path to the user's uploaded Excel file
file_path = "/mnt/data/sss.xlsx"
Let's read the data from 'Sheet1'
try: sheet1_data = pd.read_excel(file_path, sheet_name='Sheet1', skiprows=3) # Skip the first 3 rows based on earlier inspection
# Calculate the total brokerage as the starting point
total_brokerage = sheet1_data["Brokerage"].sum()
# Define the growth projection parameters
months = 12
growth_rate = 2
projection_values = [total_brokerage * (growth_rate ** i) for i in range(1, months + 1)]
# Prepare the data for the projection sheet
growth_projection_df = pd.DataFrame({
"Month": list(range(1, months + 1)),
"Projected Value": projection_values
})
# Path to save the updated Excel file
output_file_path = "/mnt/data/updated_growth_projection.xlsx"
# Write the projection data to a new Excel file
with pd.ExcelWriter(output_file_path) as writer:
growth_projection_df.to_excel(writer, sheet_name="Growth Projection", index=False)
sheet1_data.to_excel(writer, sheet_name="Sheet1 Data", index=False)
output_file_path
except Exception as e: str(e)