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

Posted October 14, 2017 9k views
UbuntuServer OptimizationDebianDjangoApplications

i run this code i terminal

$ python3 runserver ‘my ip address:8000’

and the result is

Traceback (most recent call last):
File “”, line 22, in <module>
File “/usr/local/lib/python3.5/dist-packages/django/core/management/”, line 364, in executefromcommandline
File “/usr/local/lib/python3.5/dist-packages/django/core/management/”, line 308, in execute
File “/usr/local/lib/python3.5/dist-packages/django/conf/”, line 56, in _getattr__
File “/usr/local/lib/python3.5/dist-packages/django/conf/”, line 41, in _setup
wrapped = Settings(settingsmodule)
File “/usr/local/lib/python3.5/dist-packages/django/conf/”, line 110, in _init__
mod = importlib.importmodule(self.SETTINGSMODULE)
File “/usr/lib/python3.5/importlib/”, 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/”, line 28
ALLOWED_HOSTS = [my ip address]
SyntaxError: invalid syntax

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Put ALLOWED_HOSTS = '*' and then run your command line like python3 runserver if you’re running in the same machine.