0

I'm new to Python and Django, and I'm following this tutorial to learn some Django basics. I keep getting a DisallowedHost error. (Screenshot: https://ibb.co/c1beYG)

As per this post, I added 'chocoberrie.pythonanywhere.com' to the ALLOWED_HOSTS list in settings.py, and I made sure to include it in quotation marks and keep the brackets. I even added it to requests.py, at line 113 (indicated in the error message).

Additional screenshots: https://ibb.co/jwUNnb and https://ibb.co/fbmrfw

I also committed the changes to Git, and I double-checked the repository to make sure that the URL was added to ALLOWED_HOSTS. I also made sure to reupload the changes on PythonAnywhere.

After all that, I'm still getting the error! It's really frustrating, and I don't know what else to do. Any help would be much appreciated!

Note: I did see a way to "disable" this error in this post, but I'm using a newer version of Django, so I don't know how to apply this.

Dee
  • 11
  • 3
  • can you post the exact line you currently have for ALLOWED_HOSTS in your settings.py file on pythonanywhere? – hwjp Nov 14 '17 at 11:37
  • 1
    @hwjp Ah ha! That's where the problem was! Here is the exact line in settings.py on PythonAnywhere: ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com'] I had to replace with my username. Thanks so much! I didn't know that the settings file online could be different. Do you know why that happened? – Dee Nov 14 '17 at 12:43
  • i'm not sure how it might have happened, but you can use git from both your own pc and from the server to synchronise your code between pythonanywhere and your machine -- i think the DG tutorial has some suggestions on how to do that... – hwjp Nov 14 '17 at 15:34
  • Thanks so much! I know how to use Git on my computer, but I'm not sure how to configure it in the Bash console on PythonAnywhere. Is the tutorial here on Stack Overflow? I'll search for it! – Dee Nov 14 '17 at 21:26

1 Answers1

1

I did the same tutorial! To solve this problem you have to go in the settings.py file of your django application. You will find ALLOWED_HOST setting which will be blank by default. Enter the following replacing your pythonanywhere name with your's:- '<your-pythonanywhere-name>.pythonanywhere.com' now git pull in bash console and reload the website!

ashu
  • 11
  • 1