Reputation: 747
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.
Upvotes: 6
Views: 6550
Reputation: 747
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"
Upvotes: 3
Reputation: 626
Yes you can.
What you have to do is set up a management command and edit the runserver.DEFAULT_PORT variable for each app.
Follow the steps below to achieve this:
import django.core.management.commands.runserver as runserver runserver.DEFAULT_PORT="Your preferred port"
Note: You have to do this for both apps.
Then just import its Command class.
from django.core.management.commands.runserver import Command
Upvotes: 2