Live data from Hacker News

What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

bitecode.dev

1–10 of 63 posts

Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

#4
post #3

Django getting background tasks built-in is going to be really nice. It sucked having to manage celery or similar alongside it.

You should check out Huey next time. It is a lifesaver for us. Allows us to do the tasks via SQLite db

Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

#5
post #3

Django getting background tasks built-in is going to be really nice. It sucked having to manage celery or similar alongside it.

You should check out Huey next time. It is a lifesaver for us. Allows us to do the tasks via SQLite db

Yeah that looks really promising. Haven't done Django as my daily driver for a few years now, and I don't recall stumbling upon it back then!

Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

#6
My real pain point as a user with Django is deployment. Python is so much easier to write, but javascript is so much easier to deploy.

I wish they could make it easy to deploy django or other python framework in a serverless function with decent security baked in.

Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

#8
What I love about Django is that you can create a Django project with just one file.

You can turn a fresh Debian machine into a running Django web app by just doing:

    apt install -y python3-django apache2 libapache2-mod-wsgi-py3
And then creating the one file Django needs:

/var/www/mysite/mysite/wsgi.py:

    import os
    import django
    from django.core.wsgi import get_wsgi_application
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.wsgi')
    application = get_wsgi_application()

    ROOT_URLCONF = 'mysite.wsgi'
    SECRET_KEY = 'hello'

    def index(request):
        return django.http.HttpResponse('This is the homepage')

    def cats(request):
        return django.http.HttpResponse('This is the cats page')

    urlpatterns = [
        django.urls.path('', index),
        django.urls.path('cats', cats),
    ]
And then telling Apache where to look for it:

/etc/apache2/sites-enabled/000-default.conf:

    ServerName 127.0.0.1
    WSGIPythonPath /var/www/mysite
    
        WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
        
            
                Require all granted
            
        
    
And voilá, you have a running Django application, which you can expand upon to any size and complexity.

If you want to try it in a docker container, you can run

    docker run -it --rm -p80:80 debian:12
perform the steps above and then access the Django application at 127.0.0.1

Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

#9
post #8

What I love about Django is that you can create a Django project with just one file. You can turn a fresh Debian machine into a running Django web app by just doing: apt install -y python3-django apache2 libapache2-mod-wsgi-py3 And then creating the one file Django needs: /var/www/mysite/mysite/wsgi.py: import os import django from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MO…

This is one of the core criticisms of Django and python web backends.

WSGI is old tech that in your example requires extra packages and code in project to work. By now Python should stand on its own and handle this independently, being proxied to by better http servers like nginx or caddy.

Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn

#10
Oh man, I wish this was a bit more mature. I am writing a distributed image processing app right now with Celery, Flask, and SQLAlchemy, but I am finding it difficult to KISS. I was tempted to use Django but couldn't justify the overhead. If they get this cleaned up in the next year that would be awesome!
Post reply on HN