• 虚拟机 django 端口无法连接


    我的虚拟机django服务器为192.168.27.100,使用启动命令python manage.py runserver 9001启动后,发现笔记本电脑的游览器无法连接

    python@qinhan MyCrazyeyes]$ python manage.py runserver 9001
    Performing system checks...
    
    System check identified no issues (0 silenced).
    March 13, 2018 - 17:35:47
    Django version 2.0.1, using settings 'MyCrazyeyes.settings'
    Starting development server at http://127.0.0.1:9001/
    Quit the server with CONTROL-C.
    Performing system checks...

    经过百度发现首先要view settings.py ,将ALLOWED_HOSTS改为*

    [python@qinhan MyCrazyeyes]$ view settings.py 
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '%7noe(d-i*qxjunhtg(bg8+rkyd3yzelz&3m-o3^_1*d!i04!f'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True
    
    ALLOWED_HOSTS = ['*']
    
    
    # Application definition
    
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'web',
    ]

    随后启动命令必须用ip+端口方式启动

    ^C[python@qinhan MyCrazyeyes]$ python manage.py runserver 192.168.27.100:9001
    Performing system checks...
    
    System check identified no issues (0 silenced).
    March 13, 2018 - 17:43:35
    Django version 2.0.1, using settings 'MyCrazyeyes.settings'
    Starting development server at http://192.168.27.100:9001/
    Quit the server with CONTROL-C.

     这样就可以访问了

  • 相关阅读:
    2017-5-2 对话框控件
    2017-4-28 ListView控件
    2017-4-27 WinForm 布局及容器控件
    jQuery与Aiax应用
    jQuery中的动画
    jQuery中的事件
    jQuery中的DOM操作
    认识jQuery
    h5
    js动画效果
  • 原文地址:https://www.cnblogs.com/qinhan/p/8571335.html
Copyright © 2020-2023  润新知