DEV Community

Cover image for Why ASGI is Replacing WSGI in Django

Why ASGI is Replacing WSGI in Django

Max Ong Zong Bao on January 19, 2020

Introduction When I first learnt about how to deploy my Django website. I took the easy route which was deploying it on Heroku. Ther...
Collapse
 
dmaina5054 profile image
Daniel Maina

Thanks a lot Max. I am using pythonanywhere to deploy my Django projects. The problem though is setting environment variables. I have tried to use python-dotenv but it's still some pain in the a**. Would appreciate if you made an article on the same. Thanks

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

Hmm.. haven't been using pythonanywhere for a while. I might think of writing it soon.

Collapse
 
dmaina5054 profile image
Daniel Maina

Thank you..how do you set your environment variables. I am deploying a project that requires twitter api credentials.

Thread Thread
 
steelwolf180 profile image
Max Ong Zong Bao

Did you try this?

Thread Thread
 
dmaina5054 profile image
Daniel Maina

Yes i did. That is what i was following. I can get the SECRET_KEY in my bash shell but the code provides an error that the secret_key environment variable is not set.

Collapse
 
jheld profile image
Jason Held

I concur that some of the patterns that "require" reliance on a task queue do go away with ASGI/event-loop. However, ASGI is not a task queue -- it does not have the same power and resilience built-in. Depending on what your application is doing, you'll likely end up needing to rely on those technologies, still.

That being said, the point is valid: lightweight tasks may be able to be moved into ASGI land!

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

Nice I think there's multiple ways to skin a cat for task queue. Due to it's being relevant for a while now but let's us look at the development for it.

Collapse
 
czep profile image
Scott Czepiel

ASGI is an excellent idea! I've deployed countless sites using tried and true mod_wsgi with Apache. But as the back-end is quickly moving to REST, with app logic increasingly built into JavaScript payloads, server driven template frameworks are becoming less versatile. I think ASGI is a welcome compromise to keep Django relevant.

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

Yup it is that is why Django should change with the times if not it will fade away in not being used anymore.

Collapse
 
perigk profile image
Periklis Gkolias

Thank you for the introduction Max. I was looking to write something similar.

The next big milestone for jungle in my humble opinion is the orm to natively support nosql.

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

Hmmm..I don't really think so I think it might be good to have GraphQL support by default will be good.

Than again there is a Django package for it so there is nothing really that bad with it.

Collapse
 
perigk profile image
Periklis Gkolias

Are you talking about djongo? I'm not aware of any other to be honest, can you throw me a link?

I think the graphql integration can be achieved very nicely with the graphene module.

Thread Thread
 
steelwolf180 profile image
Max Ong Zong Bao

Yup that is the graphene module.

Collapse
 
idrisrampurawala profile image
Idris Rampurawala

Thanks for introducing ASGI Max. I have been using Gunicorn for Django too. You might wanna check post on dev for the same.

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

It's not really that relevant for my article but well as long as it helps the Django community I don't mind.