Yeah I guess I understood that, but working in Django myself I don’t quite get the point of it. Is it some older lighter version of Django and what for? I think this was more my point.
Author here. In 2007 when Django was starting to get popular there was a website called instantdjango.com where you could go and download a zip that would let you run Django and Python on Windows, with everything configured nicely.
I only used that version because it is the official one supported by cosmopolitan, but it is also possible to use newer versions with the same approach, for example Python 3.11 and Django 4: https://github.com/ahgamut/cpython/tree/cosmo-djngo (Website has been updated to point at that one).
djngo.com is the culmination of years of effort, creating a single file python executable that runs on all platforms. This project is based on APE (https://justine.lol/ape.html) and in the past few days, our Python APE port (called python.com) became good enough to run Django. So we put Django inside the executable too, and called it djngo.com. The djngo.com executable will just work on the following platforms:
- Apple x86_64 and ARM64
- Linux running x86_64 or ARM64 (Raspberry Pi)
- Windows running x86_64 and possibly ARM64 too
- FreeBSD, NetBSD, and OpenBSD running x86_64
It does not require that Python be installed beforehand. It's a native Python executable. It does not require Rosetta or Qemu be installed either, in order to run ARM64 platforms. It does not require Cygwin or MSYS2 runtimes in order to run on WIN32. It only depends on KERNEL32. It has an embedded JIT VM called Blink (https://github.com/jart/blink) which it pulls out on non-x86 platforms to emulate itself. All its dependencies are bundled inside using a zip polyglot, including the Python standard library:
You can put your app's assets inside the djngo.com file too, using the standard zip tool. You can then rename the file, and insert a `.args` file that supplies default args for launching your white-labeled app.
This means that if you're a Django app developer, you can now easily share your apps with others wanting to run it locally. It's almost as easy for anyone on any platform to use, as if you productionized it onto a website. Rather than a hyperlink away, it's a single file download and CLI invocation away. You won't need to explain things like, "here's how you install Python on Windows" or "here's how you install Docker and setup a Linux distro, in order to run my app." Your users will be in full control of the app, granting maximum privacy and control over data, and zero operations toil for you!
Why Django 2.2? That version is no longer supported, and I'm guessing there's some technical reason you are using the obsolete version? (Production Django is now on major version 4)
The technical reason for choosing Python 3.6 no longer applies due to how quickly cosmo has advanced in the past months (in particular thread support). jart and ahgamut were the ones who made it happen, I am only a python.com user.
But if you want Django 4 and Python 3.11, here is some info copied from the website:
3. Newer Python and newer Django? It is possible to have a djngo.com with Django 4 and Python 3.11. Solved by aghgamut who was the first to port Python to Cosmopolitan.
Please note that this Python and the one that djngo.com use are different, the later has been heavily optimized by jart to run well on cosmo, the former is as close as upstream as you can get. Choose your destiny.
The cosmo monorepo currently vendors Python 3.6, since cosmo originally didn't have threads support and that was the last version before threads became mandatory. I'm pretty happy with the old version since I've been using Django since the 2000's. I put a lot of work into enhancing monorepo cosmo python with things like a better REPL that works across platforms. It may not be supported by the Python team, but it's supported by me. However the future will probably be building Python w/ Cosmo outside the monorepo. See the other comments for details on how to use APE + Python 3.11 for a modern experience.
Python 3.11.0rc1, Django 4.1.7. I think ingenieroariel also has a binary available on the website.
It's a proof-of-concept (because I wrote it just a few hours back), but it shows that we could have the latest version of Python+Django packaged in a single-file executable. Someone could definitely improve upon the build process (like it was done for Python3.6) and add more packages if they wanted.
FWIW I imagine we could have added Django to `python.com` sometime last September, which is when I ported Python 3.11.0rc1 (with threads!) to Cosmopolitan Libc: https://github.com/ahgamut/cpython/tree/cosmo_py311
This seems great. I do not have a clue as to what are the best ways to get a modern Python GUI app running, but I can absolutely slam together a Django application to make a web form. Hugely lower barrier to entry than trying to tackle Electron.
Is it efficient or web scale? Probably not, but I will definitely consider this rather than say Gooey.
Are people still using a mature, stable, battle-tested framework with tons of third-party resources, great documentation and excellent coverage of many business needs ?
I've seen this opinion on HN for years, but still don't _really_ understand it. Our cofounder built what is now a $1B+ SaSS company from some cursory SQL knowledge he gained while interning at a hospital in the early 2010's. The entire business is, in essence, a fancy graphical UI around postgres.
I've now been writing django at work for five years and still have yet to come across a query builder/orm which is as powerful yet simple in addition to being a breeze to on-board new engineers with.
When there are queries that require the use of non-django builtins, it's also relatively easy to use django raw sql or just straight up use the psycopg2 sql.SQL dynamic string composition helpers.
With the complexity of some our chained django QueryMethods, the company would have quite literally been impossible to build without django's query builder, at the very least.
This is a double-edged sword in my opinion. The Django ORM is among my favourite ORMs, but the abstraction (like any) can cause problems over time.
At scale, poorly understood ORM-generated queries can be a real pain, especially if your team's SQL skills have atrophied due to over-reliance on the ORM.
As an exercise, I'd possibly recommend reviewing your top 1-3 worst performing queries, tracking them back to the ORM, and evaluating how to improve them.
I completely agree, except for the last line. It is in my experience very hard to post-hoc get people to care about query performance. Organizationally and technically. In a complicated monolith at scale, de-tangling the ORM is a multi-years long project.
Edited to say: as for the average website, I do completely agree. For the unique website that will scale as well, I likely would still 95/100 recommend the ORM, but my experience has taught me that there be some pain on the road.
After a few years around the block (meteor, next.js), I'm back to Django. Got an mvp planetary web map annotation app up in no time, using Django DRF and just some plain hand-written js. Feels great to be back.
Not to be condescending or patronizing, but, well, I'm answering your question and it itself has a dismissive tone.
Yes, people are still using Django.
As I've grown in my career, frameworks, libraries, and architectural patterns just become tools. I don't quite understand folks who identify as a "React developer", or a "Django developer". When evaluating any framework, you must learn to eschew the latest hotness long enough to evaluate what your requirements are, and maybe most importantly, what your constraints are.
For a surprising amount of projects today, I would still recommend Django above anything else.
A lot. And it baffles me why hasn't anyone realized that Kenneth Reitz was right about django over a decade ago and all his points are equally valid today.
If you like Flask (I do too), you can do what we used to do before Flask existed (./djngo.com -p project runserver) where .python/project.py in the zip is:
import os
from django.conf import settings
from django.core import management
from django.conf.urls import url
from django.http import HttpResponse
# Django 2.2 Release Notes
# https://docs.djangoproject.com/en/4.1/releases/2.2/
# Documentation
# https://docs.djangoproject.com/en/2.2/
__version__ = 0.1
DEBUG = True
ROOT_URLCONF = 'project'
DATABASES = {'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'project.db' }}
SECRET_KEY = os.getenv('SECRET_KEY', 'Please set a SECRET_KEY as an env var.')
if not settings.configured:
settings.configure(**locals())
def index(request):
return HttpResponse('Hello Django!')
urlpatterns = [
url(r'^$', index),
]
if __name__ == '__main__': # pragma: no cover
management.execute_from_command_line()
I will take a well curated package that handles all the problems for me rather than bolting together pieces just so I can feel more ownership of a project.
- Admin panel? Django has me
- Web forms? Django has me
- Testing? Django, again has an out of the box solution
- Latest in security practices[0]? Again, covered for free
Flask, boy oh boy. I want an ORM? Guess I have to search around, Flask-SQLAlchemy has a lot of hits, I guess? Emails? Well, the Flask Mega-Tutorial uses Flask-Mail[1], guess I will use that. Oh look, it has not been updated since 2014[2]. Hope there is not a security flaw in there[3].
Django follows best practices, and has a huge community ensuring that there is adequate coverage and features required for modern development.
FastAPI is the better choice now as its ecosystem is much more up to date and has more batteries included than flask (eg FastAPI has authentication included).
Well no. None of these thing are appealing to me. As much as I hate the modern web, admin panels and forms generated server side are dead. Testing has never been an issue. As for security practices, this statement is as subjective as they come.
I am by no means a fan of flask. However it gives you a lot more freedom to structure your application to your taste. Django is basically a php 5.4 framework with a python syntax.
In this day and age fastAPI is a solid choice, so is falcon and probably half a dozen others.
I find https://django-ninja.rest-framework.com/ even more awesome these days because it natively integrates with Django ORM, which I prefer over alternatives such as SQLAlchemy.
I would suggest Masonite [0]. It’s lightweight enough to replace Flask and has a plethora of built in features if you need to build a “production-ready” app. It tends to imitate Laravel in its project setup and naming conventions which, depending on your preference, can either be a boon or a bane.
References to slavery in America, even references to movies of freed slaves struggling to free others are generally unwelcome. It’s not something most people want to be faced with when they just came for a simple technical discussion.
I found it clever and I welcome it. The history surrounding slavery isn't a taboo subject, what a ridiculous idea. The commenter in no way is condoning slavery.
Yep, as a black person in the USA… this sort of reads as:
“Remember those times your ancestors were enslaved?
Which relates to a history of segregation and oppression so recent that your parents were alive when it was overturned? You must remember it since it’s still championed by secessionists and is the cause of ever present police brutality.
Remember that? Well wow, do I have a funny joke for you!”
Long story short, there are other jokes that could be made.
References to religions as true are generally unwelcome. It's not something most people want to be faced with when they just came for a simple technical discussion.
Oh no this is totally just my opinion, and I can only defend it with rhetoric, anecdotes, and common sense logic.
Don’t get name wrong, I don’t think the OP meant something malicious and I don’t want to word police in general. It’s just that this joke comes up all the time when Django is mentioned in a crowd. It may have been funny once but now it’s just kind of banal.
Hmm, this has me thinking I could build a single-file executable with a self-contained database or that connects to the server. And with a little work I might be able to launch the system browser pointed at the Djngo. And with this I might have a simple web based replacement for all the Access utilities floating around here?
I know about Electron and Tauri and all that but this seems like an intriguing possibility to work on.
Tunney-jart, ape, etc are so impressive... I'd like to see some real competition for Access, at least on Linux and/or BSDs. Because Access is untouchable in it's space. Because it _is_ the space. redbean looks very tasty indeed. If it was the foundation of an 'Access-on-GNU/Linux/BSD' that would be very cool.
I really should try redbean. Python / Django is attractive for the batteries included aspect and some uses I had in mind might look for those batteries but a quick search shows some of those are available for Lua so maybe I should get a proof of concept together.
70 comments
[ 3.2 ms ] story [ 141 ms ] threadIt's mentioned right there
I only used that version because it is the official one supported by cosmopolitan, but it is also possible to use newer versions with the same approach, for example Python 3.11 and Django 4: https://github.com/ahgamut/cpython/tree/cosmo-djngo (Website has been updated to point at that one).
- Apple x86_64 and ARM64
- Linux running x86_64 or ARM64 (Raspberry Pi)
- Windows running x86_64 and possibly ARM64 too
- FreeBSD, NetBSD, and OpenBSD running x86_64
It does not require that Python be installed beforehand. It's a native Python executable. It does not require Rosetta or Qemu be installed either, in order to run ARM64 platforms. It does not require Cygwin or MSYS2 runtimes in order to run on WIN32. It only depends on KERNEL32. It has an embedded JIT VM called Blink (https://github.com/jart/blink) which it pulls out on non-x86 platforms to emulate itself. All its dependencies are bundled inside using a zip polyglot, including the Python standard library:
You can put your app's assets inside the djngo.com file too, using the standard zip tool. You can then rename the file, and insert a `.args` file that supplies default args for launching your white-labeled app.This means that if you're a Django app developer, you can now easily share your apps with others wanting to run it locally. It's almost as easy for anyone on any platform to use, as if you productionized it onto a website. Rather than a hyperlink away, it's a single file download and CLI invocation away. You won't need to explain things like, "here's how you install Python on Windows" or "here's how you install Docker and setup a Linux distro, in order to run my app." Your users will be in full control of the app, granting maximum privacy and control over data, and zero operations toil for you!
But if you want Django 4 and Python 3.11, here is some info copied from the website:
3. Newer Python and newer Django? It is possible to have a djngo.com with Django 4 and Python 3.11. Solved by aghgamut who was the first to port Python to Cosmopolitan. Please note that this Python and the one that djngo.com use are different, the later has been heavily optimized by jart to run well on cosmo, the former is as close as upstream as you can get. Choose your destiny.
curl -O https://djngo.com/djngo4-py311.com
Python 3.11.0rc1, Django 4.1.7. I think ingenieroariel also has a binary available on the website.
It's a proof-of-concept (because I wrote it just a few hours back), but it shows that we could have the latest version of Python+Django packaged in a single-file executable. Someone could definitely improve upon the build process (like it was done for Python3.6) and add more packages if they wanted.
Making Django work on Py3.11 involved the following steps (see commit history for https://github.com/ahgamut/cpython/tree/cosmo_djngo):
- add django + deps to the Lib/ folder - add sqlite3 and zlib to the build system - run quick tests and small examples to check the build works
I expect there's a bunch of packages like django which can be ported similarly. If anyone's interested, this is a fun area to explore.
[1] https://news.ycombinator.com/item?id=34857435
Is it efficient or web scale? Probably not, but I will definitely consider this rather than say Gooey.
Yes, of course.
I've now been writing django at work for five years and still have yet to come across a query builder/orm which is as powerful yet simple in addition to being a breeze to on-board new engineers with.
When there are queries that require the use of non-django builtins, it's also relatively easy to use django raw sql or just straight up use the psycopg2 sql.SQL dynamic string composition helpers.
With the complexity of some our chained django QueryMethods, the company would have quite literally been impossible to build without django's query builder, at the very least.
At scale, poorly understood ORM-generated queries can be a real pain, especially if your team's SQL skills have atrophied due to over-reliance on the ORM.
As an exercise, I'd possibly recommend reviewing your top 1-3 worst performing queries, tracking them back to the ORM, and evaluating how to improve them.
People often overestimate how often the average website needs to worry about scale.
And how easy it is to fix the times you come close.
Edited to say: as for the average website, I do completely agree. For the unique website that will scale as well, I likely would still 95/100 recommend the ORM, but my experience has taught me that there be some pain on the road.
Yes, people are still using Django.
As I've grown in my career, frameworks, libraries, and architectural patterns just become tools. I don't quite understand folks who identify as a "React developer", or a "Django developer". When evaluating any framework, you must learn to eschew the latest hotness long enough to evaluate what your requirements are, and maybe most importantly, what your constraints are.
For a surprising amount of projects today, I would still recommend Django above anything else.
https://speakerdeck.com/kennethreitz/flasky-goodness
With that being said, I hadn't thought much about "before Flask". I very well might feel differently if I had been coding then.
- Admin panel? Django has me
- Web forms? Django has me
- Testing? Django, again has an out of the box solution
- Latest in security practices[0]? Again, covered for free
Flask, boy oh boy. I want an ORM? Guess I have to search around, Flask-SQLAlchemy has a lot of hits, I guess? Emails? Well, the Flask Mega-Tutorial uses Flask-Mail[1], guess I will use that. Oh look, it has not been updated since 2014[2]. Hope there is not a security flaw in there[3].
Django follows best practices, and has a huge community ensuring that there is adequate coverage and features required for modern development.
[0]: https://docs.djangoproject.com/en/4.2/releases/4.2/ note on the BREACH attack
[1]: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial...
[2]: https://github.com/mattupstate/flask-mail
[3]: https://github.com/mattupstate/flask-mail/issues/189
I am by no means a fan of flask. However it gives you a lot more freedom to structure your application to your taste. Django is basically a php 5.4 framework with a python syntax.
In this day and age fastAPI is a solid choice, so is falcon and probably half a dozen others.
[0] https://docs.masoniteproject.com/
I'm running
and I get I'm on a M1 Mac. Am I missing something obvious?I tried running it anyway (smart I know) and it failed with
Does the sha256sum command return a different value? It doesn't seem to be installed on my Mac by default.
If you need any help getting started, please join us on the Redbean Discord: https://discord.gg/eHtVmUEB
Do the Cosmopolitan/Blink/αpε hacks only work w/ bash on arm macos?
edit: looks like it's a known issue https://github.com/jpe90/hello-cosmo#note-running-with-zsh
They're just saying they don't want to have to think about slavery when choosing software which seems not unreasonable to me.
“Remember those times your ancestors were enslaved?
Which relates to a history of segregation and oppression so recent that your parents were alive when it was overturned? You must remember it since it’s still championed by secessionists and is the cause of ever present police brutality.
Remember that? Well wow, do I have a funny joke for you!”
Long story short, there are other jokes that could be made.
As a competent HN reader you certainly are basing your view on some facts?
Don’t get name wrong, I don’t think the OP meant something malicious and I don’t want to word police in general. It’s just that this joke comes up all the time when Django is mentioned in a crowd. It may have been funny once but now it’s just kind of banal.
https://www.youtube.com/watch?v=ANArGmr74u4
And, err.. well, the very namesake of the project to begin with.
I know about Electron and Tauri and all that but this seems like an intriguing possibility to work on.
https://redbean.dev/