Forums

Troubleshooting Issues with Displaying Qibla Direction Using PythonAnywhere

I am working on a web application that provides a "qibla en ligne" feature, allowing users to find the direction of the Qibla based on their location. I've deployed the application on PythonAnywhere, but I'm encountering issues with the Qibla direction not displaying correctly.

Here are the specifics of the problem:

Functionality Issue: The Qibla direction calculation seems to be correct when running locally but shows discrepancies on the PythonAnywhere server. I'm using the qibla library to calculate the direction based on latitude and longitude.

Deployment Details: The application is a Django project with a PostgreSQL database. I've ensured that the correct environment variables are set on PythonAnywhere.

Error Messages: No specific error messages are being logged, but the Qibla direction displayed is consistently incorrect.

Code Snippet: Below is a simplified version of the code used to calculate the Qibla direction: from qibla import Qibla

def get_qibla_direction(latitude, longitude): qibla = Qibla() return qibla.calculate(latitude, longitude) Configuration Check: I've checked the configuration settings related to timezone and location data on PythonAnywhere and they seem to be set correctly.

Could anyone provide guidance on why the Qibla direction might be displaying incorrectly when deployed on PythonAnywhere? Are there specific configurations or considerations for deploying such applications on PythonAnywhere that could be affecting the Qibla direction calculation?

Any help or suggestions would be greatly appreciated!

Where are you getting the latitude and longitude from?

The latitude and longitude are typically obtained through the user's device, either via GPS or IP-based geolocation services.

HTML5 Geolocation API: This is a common method used in web applications to get the user's current position. It leverages the device's GPS capabilities (if available) or other location services to provide accurate latitude and longitude. if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { alert("Geolocation is not supported by this browser."); }

function showPosition(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; // Send latitude and longitude to the server or use it directly in your JS code }

Then check: * that running the code with know lat/long produces the same results * that the lat/long that are being sent to PythonAnywhere are correct * that the code is interpreting the lat/long provided correctly and correctly passing it to the library