You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Django 1.10项目部署至PythonAnywhere后无法访问求助

Troubleshooting Django Deployment on PythonAnywhere for Rango

Let’s walk through the most common issues that could be stopping your Rango app from loading at danielcirstea.pythonanywhere.com/rango, even after setting DEBUG=False and configuring your host:

  • Double-check your ALLOWED_HOSTS setting
    Make sure your settings.py has the exact domain with no typos:

    ALLOWED_HOSTS = ['danielcirstea.pythonanywhere.com']
    

    Skip extra slashes or www unless you’re actively using that subdomain. If you want to support both, use ['danielcirstea.pythonanywhere.com', 'www.danielcirstea.pythonanywhere.com'].

  • Verify your WSGI configuration
    PythonAnywhere’s WSGI file needs to correctly point to your Django project’s root and settings. For example, if your project lives at /home/danielcirstea/rango_project, your WSGI file should look like this:

    import os
    import sys
    
    # Add your project path to sys.path
    project_path = '/home/danielcirstea/rango_project'
    if project_path not in sys.path:
        sys.path.insert(0, project_path)
    
    # Set the Django settings module
    os.environ['DJANGO_SETTINGS_MODULE'] = 'rango_project.settings'
    
    # Activate virtual environment if you're using one
    activate_this = '/home/danielcirstea/.virtualenvs/rango_env/bin/activate_this.py'
    with open(activate_this) as file_:
        exec(file_.read(), dict(__file__=activate_this))
    
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()
    

    Also confirm that DJANGO_SETTINGS_MODULE matches your project’s structure—if your settings are in rango/settings.py, use 'rango.settings' instead.

  • Fix static file configuration (critical for DEBUG=False)
    When DEBUG is off, Django won’t serve static files automatically. Follow these steps:

    1. Run python manage.py collectstatic in your project’s Bash console. This copies all static files into the directory specified by STATIC_ROOT in settings.py.
    2. In PythonAnywhere’s Web tab, add a static file mapping:
      • URL: /static/
      • Directory: /home/danielcirstea/rango_project/staticfiles (or whatever your STATIC_ROOT path is)
        Without this, your app might throw errors or load with broken styling.
  • Confirm your virtual environment setup
    If you’re using a virtual environment, make sure you installed Django and all project dependencies inside it. In PythonAnywhere’s Web tab, under "Virtualenv", double-check the path matches your environment (e.g., /home/danielcirstea/.virtualenvs/rango_env). If you installed packages globally instead of in the venv, the server might not find them.

  • Check the error logs
    This is the fastest way to pinpoint the issue! In PythonAnywhere’s Web tab, look at:

    • Error log: Shows runtime issues like DisallowedHost errors, missing imports, or database connection problems
    • Server log: Displays startup messages and configuration warnings
      The logs will give you specific details about what’s failing—for example, a DisallowedHost error means you need to tweak ALLOWED_HOSTS, while a static file missing error points to a misconfigured static mapping.

If you share snippets from your error logs, we can narrow down the problem even further!

内容的提问来源于stack exchange,提问作者user9092892

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:33:55