How to runserver django in ubuntu 17.04 i have created django app but when i try to run server the terminal says invalid syntax

October 14, 2017 177 views
Applications Django Server Optimization Debian Ubuntu

i run this code i terminal

$ python3 manage.py runserver 'my ip address:8000'

and the result is

Traceback (most recent call last):
File "manage.py", line 22, in <module>
executefromcommandline(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/
init.py", line 364, in executefromcommandline
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/init.py", line 308, in execute
settings.INSTALLEDAPPS
File "/usr/local/lib/python3.5/dist-packages/django/conf/
init.py", line 56, in _getattr__
self.setup(name)
File "/usr/local/lib/python3.5/dist-packages/django/conf/
init.py", line 41, in _setup
self.
wrapped = Settings(settingsmodule)
File "/usr/local/lib/python3.5/dist-packages/django/conf/
init.py", line 110, in _init__
mod = importlib.importmodule(self.SETTINGSMODULE)
File "/usr/lib/python3.5/importlib/init.py", line 126, in importmodule
return _bootstrap.
gcdimport(name[level:], package, level)
File "<frozen importlib.
bootstrap>", line 986, in gcdimport
File "<frozen importlib._bootstrap>", line 969, in findandload
File "<frozen importlib.
bootstrap>", line 958, in findandloadunlocked
File "<frozen importlib._bootstrap>", line 673, in loadunlocked
File "<frozen importlib._bootstrap_external>", line 669, in execmodule
File "<frozen importlib.
bootstrapexternal>", line 775, in getcode
File "<frozen importlib._bootstrap_external>", line 735, in sourcetocode
File "<frozen importlib._bootstrap>", line 222, in callwithframesremoved
File "/home/aditya/testdjangoapp/testsite/testsite/settings.py", line 28
ALLOWED_HOSTS = [my ip address]
^
SyntaxError: invalid syntax

1 Answer

Put ALLOWED_HOSTS = '*' and then run your command line like python3 manage.py runserver 0.0.0.0:8000 if you're running in the same machine.

Have another answer? Share your knowledge.