Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running 2 django project in different port number at the same time

Tags:

django

As what the title said, is it possible to run 2 django project at the same time ? Since by default, all django run by http://127.0.0.1:8000/. Is there anyway i can change the port number for both the django project ?

My task is this: Integration of django 1 api and django 2 api, to setup two django app, on same server / PC, with different port

As far from what i know, i can change the port number in the settings.py database section. I also cant seems to find much information about this.

The only solution i found which is running this command:

manage.py runserver 8005

will allow the django project to run in 8005 port.

But is it possible to do it without writing the command and just do it in the settings.py or other file ? As i know this is just for development phrase. If its on production, it cannot use in this way.

like image 582
Jin Nii Sama Avatar asked Jan 16 '18 07:01

Jin Nii Sama


People also ask

How do I run a Django project on a different port?

Inside the commands folder open up the runserver.py script with a text editor. Find the DEFAULT_PORT field. it is equal to 8000 by default. Change it to whatever you like DEFAULT_PORT = "8080"

What port does Django run on?

If you start your Django development server it runs on port 8000 by default.


1 Answers

I found an answer from this post: django change default runserver port

This is achieve by modifying the manage.py file by adding this line

# Override default port for `runserver` command
from django.core.management.commands.runserver import Command as runserver
runserver.default_port = "Port Number"
like image 167
Jin Nii Sama Avatar answered Sep 16 '22 15:09

Jin Nii Sama