当我使用python manage.py runserver localhost:8000
启动服务器时,它似乎正在连接,这给了我:
System check identified no issues (0 silenced).
December 25, 2016 - 00:30:23
Django version 1.9.4, using settings 'deanslist.settings'
Starting development server at http://localhost:8000/
Quit the server with CONTROL-C.
没有别的了。但是,在我的浏览器窗口中本地主机:8000告诉我一个ERR_CONNECTION_REFUSED
错误。我试过的其他港口都发生过这种情况。我一辈子都搞不清楚出了什么问题。还有人有什么想法吗?你知道吗
作为记录,我的manage.py
看起来是这样的:
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "deanslist.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
我用来设置虚拟环境的脚本如下所示:
LogFile=./setup_log
ErrFile=./setup_err
# Detect the platform
OS="`uname`"
case $OS in
'Linux')
OS='Linux'
;;
'Darwin')
OS='Mac'
;;
'AIX') ;;
*) ;;
esac
function install_mac_dependencies() {
brew update
brew upgrade
brew prune
brew install python3
if [ $(xcode-select -p) == 2 ]
then
xcode-select --install
fi
}
# Install system dependencies w/package manager for Ubuntu
function install_dependencies () {
sudo apt-get install python3-dev
}
# Setup the python virtual environment
function setup_env () {
pip install virtualenv
if [[ "$OS" == "Mac" ]]
then
virtualenv -p /usr/local/bin/python3 venv
source ./venv/bin/activate
pip install --upgrade pip setuptools wheel
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
else
virtualenv -p python3 venv
source ./venv/bin/activate
pip install --upgrade pip setuptools wheel
fi
pip install -r requirements.txt
}
function local_db_setup() {
while true; do
read -p "Run the setup script now? y/n " answer
case $answer in
[yY]* ) echo "[!] Migrating models to local database"
python manage.py makemigrations
python manage.py migrate
break;;
[nN]* ) echo "Exiting database update module..."; exit;;
* ) echo "Dude, just enter Y or N, please."; break ;;
esac
done
}
# Check script's compatability
if [[ ! "$OS" == "Linux" ]] && [[ ! "$OS" == "Mac" ]]
then
echo "[-] Exiting, setup script currently only tested on macOS Sierra and Ubuntu"
exit;
fi
# Initiate the setup
while true; do
read -p "Run the setup script now? y/n " answer
case $answer in
[yY]* ) echo "[*] Initiating setup for platform: $OS";
# Dependencies
echo "Installing python3-dev. This may require sudo privileges..."
if [ ! "$OS" == "Linux" ]
then
brew help > /dev/null
if [ $? -ne 0 ]
then
install_homebrew
else
install_mac_dependencies > "$LogFile" 2> "$ErrFile";
fi
else
install_dependencies > "$LogFile" 2> "$ErrFile";
fi
# Python Environment
echo "Creating the virtual environment..."
setup_env >> "$LogFile" 2>> "$ErrFile";
break;;
[nN]* ) echo "Exiting setup..."; exit;;
* ) echo "Dude, just enter Y or N, please."; break ;;
esac
done
# Check for errors
if [ ! -s "$ErrFile" ]
then
echo "[+] Setup successful! No errors detected"
echo "[*] Cleaning and exiting..."
rm "$ErrFile"
rm "$LogFile"
exit
else
if [[ $(wc -l <$ErrFile) -eq 1 ]]
then
if grep -q "already installed" "$ErrFile"; then
echo "[+] Setup successful! No errors detected"
echo "[*] Cleaning and exiting..."
rm "$ErrFile"
rm "$LogFile"
# Dev database setup
local_db_setup;
exit
fi
fi
echo "[-] Setup failed, check $ErrFile for errors"
fi
目前没有回答
相关问题 更多 >
编程相关推荐