tejmagar / django-channels-websocket-example

Django real-time WebSocket example. It generates a random number. Link to article: https://sagasab.com/2022/01/02/simple-django-websocket-tutorial-for-beginners/
https://sagasab.com/2022/01/02/simple-django-websocket-tutorial-for-beginners/
4 stars 3 forks source link

Commands To Run Django Server App? #1

Open jerrychong25 opened 1 year ago

jerrychong25 commented 1 year ago

Hi @tejmagar,

Thanks for creating nice articles on https://sagasab.com/blog/simple-django-websocket-tutorial-for-beginners/ as well as uploading full project codes into GitHub.

Do you mind to share full commands on running the Django server app after following your guides?

Tried running with following commands:

python3 manage.py migrate
python3 manage.py runserver

Unfortunately my end get empty screen in the browser, as per screenshot below: image

Here is full logs:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
February 01, 2023 - 17:18:51
Django version 4.1.6, using settings 'channelsdemo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Not Found: /ws/
[01/Feb/2023 17:18:57] "GET /ws/ HTTP/1.1" 404 2205

Hope your end could provide some guidances on this.

Thank you!

tejmagar commented 1 year ago

Hi, looks like you are using the latest version of Django. Please install the daphne server and include it in the installed apps.

pip install daphne

INSTALLED_APPS = [ 
'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 
'channels' ,
'daphne'
]

I will also update in the blog. Thank you for pointing it.

jerrychong25 commented 1 year ago

Hi @tejmagar ,

Thanks for sharing.

Mind to share what's original versions of django, daphne and channels you using previously when creating this tutorial?

Thank you.