Live data from Hacker News

Django 3

docs.djangoproject.com

151–160 of 196 posts

Re: Django 3

#151
post #137

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…

I just finished rewrite of big (400+K LOC) 10 year old pylons codebase to pyramid. We were able to share our models, services and 100% template code, and about 80% of view code was untouched. What you want to do is follow this recipe: https://docs.pylonsproject.org/projects/pyramid-cookbook/en/... You put a 404 handler in pyramid to delegate not found views to pylons, and move views one by one. In a pyramid tween you…

Awesome reply :)

This project has reached its end of life, as far as the owners of the site are concerned. I've just completed a 4 month revamp on it, basically giving it a facelift by moving it from hand-crafted CSS, javascript and crufty old templates, to Bootstrap 4 and a more modern look, with some new features; project "Lipstick on a pig".

The company in question has plans for new areas of business for which this site won't be able to handle. It's simply not worth spending the time, bother (and money) trying to hammer that round peg into new square holes, and hence not worth rewriting to Pyramid. The revamp mentioned above will tide them over until something more suitable (and bespoke) is created, which is where Django comes in.

Re: Django 3

#152
post #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?

Looked at fast api docs and it looks great. Curious how to interface it with an ORM or DB without duplicating model/field definitions?

Re: Django 3

#153

The community built around Django, coupled with the sheer amount of documentation and the stability of their APIs has done enough to forever ruin my expectations for any other coding project out there. Ostensibly everything else feels disorganized, poorly documented or rushly released. But the most commendable value of the DSF – which I believe is a model to be replicated – is how effectively it has managed to both a…

I echo this sentiment exactly. I don't feel like OSS projects achieve this kind of success by accident. I'd love to see some write-up of some kind on how they do it. They're definitely the gold standard in my mind.

Re: Django 3

#154
Django and Python have made me a much better developer.

Using it for more than 10 years professionally, full time with no stop.

It helped me to pay my bills, bring food to the table and build my ideas and get one step closer to my dreams.

Thank you Django and everyone around or behind or even remotely related to it.

Re: Django 3

#155
post #45
post #5

Does Python still have performance issues? That's always been my concern when considering its adoption.

Yes and no. The Python interpreter/bytecode-VM is not as fast as it could be, because only a few people work on it. PyPy is great, but not drop in. Lack of funding is the proximate cause, of course, but that's just masking the ultimate cause of lack of interest. Because people use Python as a glue, just like PHP, or Node. To do the heavy lifting you have many options. (Even in Python, you can just use Cython, use FFI…

What about the type hints they introduced? I enjoyed how you can go back and add them after the fact in separate files.

Re: Django 3

#156
post #45

Earlier quoted context omitted.

Yes and no. The Python interpreter/bytecode-VM is not as fast as it could be, because only a few people work on it. PyPy is great, but not drop in. Lack of funding is the proximate cause, of course, but that's just masking the ultimate cause of lack of interest. Because people use Python as a glue, just like PHP, or Node. To do the heavy lifting you have many options. (Even in Python, you can just use Cython, use FFI…

> PyPy is great, but not drop in. Nowadays it works correctly with almost all C modules. Mostly you just need to use `pypy3 -m pip install foo` instead of `python3 -m pip install foo`.

Last year I had to fight with it quite a bit to get it to work with uwsgi.

It seems that any new/greenfield Python project should target PyPy though, just in case, and the performance never hurts.

Re: Django 3

#157
post #117
post #112

Earlier quoted context omitted.

If you’re in the hacking mode - what do you think of taking the Django orm and grafting it onto fast api - sort of like a stand-alone sqlalchemy but with all the ease and power or django’s querysets...

Django ORM is not async so using it with FastAPI would block the event loop. I guess you could wrap the calls in sync_to_async from asgiref but it wouldn't be pretty. Another option is using something like Tom Christie's orm project ( https://github.com/encode/orm ), which is a wrapper on top of sqlachemy with a django like interface.

FastAPI runs blocking IO/sync functions in a separate thread pool to work around this issue.

Re: Django 3

#158

Earlier quoted context omitted.

Pyotr [0] is a small library I've been developing for a while, based on Starlette. In a nutshell, it takes an OpenAPI specification and turns it into an API application, taking care of all the routing and validation according to the spec. It is conceptually similar to connexion [1], but it supports async and is Python 3 only. There is also a client component, in the spirit of bravado [2]. [0] https://pyotr.readthedoc…

What's the difference from fastAPI? https://fastapi.tiangolo.com/

FastAPI generates specs from code, this generates code from specs

Re: Django 3

#159
I learned, in this order:

bottle

flask

falcon

django

Django is incredible. It was useful to start with the minimalist frameworks to understand the true value of Django when I got there.

Django is amongst my software top 10. Maybe top 5.

Re: Django 3

#160
post #138
post #120

Earlier quoted context omitted.

That's trend that I see often. The other day I saw someone providing a response to argument that when using NoSQL database you need to plan in advance how the data is accessed (so you can pick the right key). The response was "don't you need to do that in every database?". So many people immediately dismiss relational databases, then re-implement all that functionality in their apps with various bugs and performance…

> It supposedly promises you that you don't need to know SQL to use please support this assertion with an ORM whose documentation promises this. > ORM constantly will make unnecessary SQL queries and by default request all fields, as does "SELECT * FROM table" if you don't write out the fields and use a buffering database adapter (which is the case for nearly all Python database adapters), so, when using an ORM, you…

The problem is that once you start fetching specific columns in your queries, the resulting objects aren't entities, just records - i.e. it's not really object-oriented, which is the main allure of ORM.

ORMs that are more honest about this, such as SQLAlchemy, are generally better than those that try to pretend that you really are dealing with entities.

Post reply on HN