Live data from Hacker News

Django 3

docs.djangoproject.com

31–40 of 196 posts

Re: Django 3

#31

This looks neat. Does anyone have experience with using type hints and mypy with Django? Any gotchas?

No specific gotchas with type hinting, but be aware that Django has not implemented any notion of type hints. So, you lack quite the benefit of type hinting

Re: Django 3

#32

Groovy. I am excited to try out the new ASGI goodness. Last time I used Django Channels it was a constant struggle to tune it, prevent it from becoming deadlocked, etc. And the transition from Channels 1.x to 2.x was also not pleasant. I hope that Django proper did things better/differently.

Do you know if this update changes how Django Channels works?

Re: Django 3

#34

This looks neat. Does anyone have experience with using type hints and mypy with Django? Any gotchas?

I gave ‘django-stubs’ a spin on a Django 2.2 project. The ORM typings and mypy plug-in worked great. ‘.filter().first()’ and similar all returned the correct types.

Ran into a couple issues with the typing of ‘client.force_login()’ where the ‘user’ parameter was typed as the ‘get_django_user()’ which wasn’t the same as the custom user model I defined in the ‘models.py’. I also had issues with ‘from django.conf import settings’ not being the correct type so I’d suggest changing that to ‘Any’.

You might be able to override the few types that don’t work for your given setup or you can just fork the repo.

Overall, I think the pain is worth the benefits.

Re: Django 3

#35
post #30

Right as I was just about to start a new Django project... The thought going through my mind right now is "I wonder if there is some way of creating a Django project and make it resilient to future Django updates and releases with minimum fuss?" I've had to deal with ongoing and inherited legacy projects which run on Python 2.7, use the long-deprecated Pylons, for which there is no easy upgrade path other than a tota…

Perhaps it's time to think about ditching the "batteries included" monolithic frameworks like Django (Rails etc.) and start your serverless/microservices/docker/k8s/etc journey. The beauty of this type of architecture is that you don't need to worry about upgrading your entire stack just because your underlying framework bumped a version number. You can create a service w/ Pylons here, a service w/ Whatever there, an…

… and then you have to track versions in many places and test all of the various combinations yourself rather than having a third-party do it. Microservices have their advantages but they are not a magic wand for dependency management unless you’re using very little of a framework.

Edit to add: I would class an advantage of microservices if it made it easier for you to have automated tests or deployment/rollbacks, since that’s much more effective for this problem in my experience. I’ve seen people do that with monoliths and fail to do that with microservices so again, no magic wands.

Re: Django 3

#36
post #24

Earlier quoted context omitted.

I mean, what kind of performance issues were you running into? You're not going to get maximum performance out of a python program, generally. But unless your python program is using 100% cpu that's not really an issue, and there are very few cases where I'm using python and it's CPU that's slowing down the program. Mostly it ends up being some kind of IO. If you're looking to do complicated mathematical operations,…

In my experience most people creating CRUD websites with Django will hit a CPU bottleneck.

I've got more than a decade of on-and-off web-dev experience, a lot of integrating data-science projects with a web-interface, and I've never seen anything like that.

You have to work pretty hard to hit a CPU bottleneck, and I can't imagine how you'd do that building a simple CRUD website.

Can you explain a bit more about how the people you know are hitting that bottleneck? I mean I've literally built CRUD apps on an esp32 microcontroller using python, and they work performantly. If real python with a real web-framework can't do the same then something is going horrible wrong.

Re: Django 3

#37

Groovy. I am excited to try out the new ASGI goodness. Last time I used Django Channels it was a constant struggle to tune it, prevent it from becoming deadlocked, etc. And the transition from Channels 1.x to 2.x was also not pleasant. I hope that Django proper did things better/differently.

I really wanted to use Django channels for some soft real-time stuff like chat and notifications and it worked but I couldn’t get testing to work reliably (tests would just hang sometimes), so I had to use a different setup.

Re: Django 3

#38
I have been using FastAPI for the last two months (which also is an ASGI server and makes full use of annotations and type hints with mypy) and the experience has been incredible. (https://fastapi.tiangolo.com/)

If Django can now also support annotations and async code I dream of an scenario where apis can be built using this two elements.

Does anybody know a good resource to learn/catch up with this release?

Re: Django 3

#39
If you can convince your company to keep Django up-to-date with every release, I have found this to be easy and pain-free (Django has been pretty API stable since ~1.8), compared with waiting for each LTS and then being forced to jump ahead three versions each time.

You also gain access to new features as they come out, this way.

Re: Django 3

#40
post #27

Groovy. I am excited to try out the new ASGI goodness. Last time I used Django Channels it was a constant struggle to tune it, prevent it from becoming deadlocked, etc. And the transition from Channels 1.x to 2.x was also not pleasant. I hope that Django proper did things better/differently.

Not Groovy, Python! :)

Adding a smiley doesn't negate that your comment was unnecessary and of no added value to the conversation.
Post reply on HN