对django来说是新手...... 我在尝试“django-admin makemigrations”时遇到了这个错误
django.core.exceptions.ImproperlyConfigured:请求的设置 DEFAULT_INDEX_TABLESPACE,但未配置设置。你必须 要么定义环境变量DJANGO_SETTINGS_MODULE,要么调用 在访问设置之前进行settings.configure()。
尝试加载主页时也会出现此错误:
/ home /没有这样的表的操作错误:home_post
答案 0 :(得分:1)
您应该使用public class chatServer2 implements Runnable {
private int clientCount = 0;
private ChatServerThread clients[] = new ChatServerThread[50];
private ServerSocket server = null;
Thread thread = null;
//same as version3
public chatServer2(int port){
try{
server = new ServerSocket(port);//step1
System.out.println("Started the server...waiting for a client");
start(); //the chatserver's start method that goes ahead and creates a new thread
}
catch(IOException e){
System.err.println("ERROR "+e.getMessage());
}
}
public void start(){
if(thread == null){
thread = new Thread(this);
thread.start();
}
}
@Override
public void run() {//same as version 3
while(thread !=null){
try{
System.out.println("Waiting for a client...");
//now we add a new Thread and accept a client
addThread(server.accept());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void addThread(Socket socket){
if(clientCount < clients.length){
clients[clientCount] = new ChatServerThread(this, socket);
try {
clients[clientCount].open();//open the stream for the ChatServerThread client
clients[clientCount].start();//start to run the ChatServerThread client
clientCount++;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public synchronized void handle(int ID, String input)
{
System.out.println(input);
if(input.equalsIgnoreCase("bye"))
{
remove(ID);//person said bye so remove them
}
else
{
System.out.println(input);
for (int i = 0; i < clientCount; i++)
{
clients[i].send("User: " + ID + ": " + input);
}
}
}
public synchronized void remove(int ID){
int position = findClient(ID);
if(position >=0){
ChatServerThread toRemove = clients[position];
if(position <clientCount-1){
for(int i= position+1; i <clientCount; i++){
clients[i-1] = clients[i];
}
clientCount--;
}
try {
toRemove.close();//close the person's that said bye connection
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private int findClient(int ID){
for(int i=0; i<clientCount; i++){
if(clients[i].getID() == ID){
return i;
}
}
return -1;//not in the array
}
public static void main(String [] args){
chatServer2 l = new chatServer2(4000);
}
}
而非manage.py
在项目中运行管理命令。