Home > Back-end >  Django print statements/debug on hosted app pythonanywhere
Django print statements/debug on hosted app pythonanywhere

Time:03-13

I have a Django app working fine on the local server but when I host it on the pythonanywhere (It is a cloud-based python site), there are some issues with the rendering on the template.

While I was coding on the local server, I used to use print statements to debug the functions in views.py, but how to use print statements for debugging if the site is deployed on the web because after hosting it on the pythonanywhere, I am unable to find where the output of the print statements goes to?

Please suggest another way, if this is not feasible, to get the backend output after deploying the Django web app. Thanks for the help.

CodePudding user response:

To do so you have to go on:

1)your web app: you have to replace yourusername by your real username in pythonanywhere.com
https://www.pythonanywhere.com/user/yourusername/webapps/#tab_id_yourusername_pythonanywhere_com
2) scroll to bottom where you can see : Log files and in this section your will find a server log click on that and you will be redirected to an other page where you can scroll to bottom from there you can see the print from your views.
i hope you understand and sorry for my poor english.

Short Solution

visit the server log file here
https://www.pythonanywhere.com/user/yourusername/files/var/log/yourusername.pythonanywhere.com.server.log replace yourusername by your real username in pythonanywhere

  • Related