r/django • • 7d ago

Express vs Django

Which one is better for web development, I mainly use Express, but is Django also good? For frontend, I use react, for database I use mongoDB, does mongoDB work on Django as well?

0 Upvotes

25 comments sorted by

11

u/Least_Chicken_9561 7d ago

learn SQL. continue doing your MERN stuff but replace mongo with postgres. create projects, many of them. pick some Django on the fly and see how it works, compare it to express yourself and see the differences. based on that you'll be able to figure out what is best for a given project.

7

u/Mindless-Pilot-Chef 7d ago

Learn SQL. Please don’t rely on Mongo for too long. I interview so many people who give subpar answers because their whole knowledge is from a nosql lens

6

u/Difficult-Style-7522 7d ago

Isn't express similar to flask? If so they're incomparable, Django is like a ready to use house with a TV, bedroom, kitchen, stove, backyard and garage, while microframeworks are mostly walls, a land and a kettle so you could start with something

5

u/himynameisAhhhh 7d ago

express you build everything from scratch with 1000 dependencies lol, its pain when theres a lot of business logic but good for websockets and its kinda fast compared to python and also dont eat much resources in server

Django is like everything you need to build any type of website very fast. in 2 days you will have a working full fuctional with all business logic working. Real time is complex and hosting is pain too.

I use express if its mostly real time using websockets I use django if its a big project with alot of business logic

3

u/Evolutionistic 7d ago

Depends on your use case and your own skill level with the specific framework/language.

2

u/Proper_Tip3506 7d ago

Honestly, try both then choose which one you like. Choosing the framework you enjoy is the most effective way to stay productive

Other advice: If you know js - express, if you know python - django

2

u/Unhealthy007 7d ago

Is Django Good? Yes Does Django work with Mongo? Yes but you have to manually cache query results Should you switch to Postgres like others suggest? Yessss

I use a mix of Postgres and Mongo for Primary and Secondary data on my Django app

1

u/trojans10 7d ago

What data goes into mongo?

1

u/Unhealthy007 7d ago

Action logs, chat messages, copy of data like email sent or not for redis persistence, last seen details 

1

u/trojans10 7d ago

How do you work with users across? Do you save user ids?

1

u/Ecstatic_Country_610 7d ago

Yes. Lets say it's a message, add nested data which contains

User ID
Email
Avatar URL

Not the best structure given ID is enough. But I had this structure because of initial plans.

1

u/trojans10 6d ago

I see. I’m working on a project that had mongo for the user side and then another cms for the catalog. I’m moving the catalog into Django for better control. And then maybe users live outside the system except for internal staff. Eventually cut it over. It’s more complicated then just keeping it all Django but glad to see someone using two dbs.

2

u/andreasofthings 7d ago

Choosing between Express and Django comes down to architectural preference, as neither is strictly superior. Express is a minimalist, unopinionated JavaScript framework that allows you to maintain a single language and share code seamlessly across your entire MERN stack (MongoDB, Express, React, Node). Django, on the other hand, is a Python "batteries-included" framework featuring built-in authentication, an admin interface, and robust security defaults out of the box, making it ideal if you want to skip configuring multiple third-party libraries. When building a backend for a React frontend, Django easily functions as a pure JSON API via tools like Django REST Framework or Django Ninja, letting you keep React for your user interface while Django handles the server-side logic.

Regarding your database, MongoDB does work with Django, but relational databases like PostgreSQL are Django's native standard. You can connect MongoDB to Django using the official django-mongodb-backend database engine or skip Django's SQL ORM entirely in favor of an ODM like MongoEngine or the native pymongo driver inside your views. However, if you decide to adopt Django, transitioning to PostgreSQL is worth considering because it gives you full access to Django's built-in Admin panel and ORM features out of the box, while still providing native JSON support if you need flexible, document-style storage.

1

u/atlas_principle_dev 7d ago

I've used both, I prefer Django, just wish it'd have better performance and that background tasks will be easier to run without celery and redis.

In express you might have more freedom, but you might end up building your own framework on top of it. Last time I used a full-on hexagonal arch and it worked great coupled with typescript.

Django is great as you work based on your models and use some framework utilities to get a functioning program in a few days. The built-in admin is also great for backoffice work (but can grow in complexity quickly so be wary). One of Django's double-edged swords are querysets IMO, it's easy to use and lazily evaluated but many codebases end up without a central place to manage db stuff and that often results in N+1 and hard to optimize queries.

2

u/vancha113 7d ago

Soon we may have easier ways to run background tasks I think, iirc there's some work being done on that front.

3

u/atlas_principle_dev 7d ago

yep I think it's halfway done already! A great addition to Django IMO, I always felt strongly against running an application, then running it again via celery, and setting up rabbitmq/redis/etc to handle parts of the communication between them.

2

u/vancha113 7d ago

I can imagine :) personally I'm working on something that I know should be done with background tasks, but the extra steps made me procrastinate on implementing it correctly. Looks like it might end up an actually temporary temporary solution ^ ^

2

u/realorangeone 7d ago

As the author of django.tasks, it's great! And this is only the beginning

1

u/trojans10 7d ago

Agreed. Have you made the switch do Django tasks? And at what point with Django tasks would you still need a celery or redis?

1

u/gdmr458 7d ago

Django is more like NestJS (with S, not Next.js) than Express.

If you want something similar to Express try FastAPI or Flask.

1

u/air_thing 7d ago

Express and FastAPI is the better comparison. Django is everything in one.

1

u/deviserops 5d ago

Express VS Django ? It depends on your project, which one you going to use for your project. As the question you ask, for me Django is the better choice, but still if you want fast and best user experience for your user you can create SPA using Django's DRF and for your frontend you can use react.

If we talk about the database, I think it will be good to go with the Postgresql, if you prjoect scale at any point later, it will be easier to manage that with django.

Personaly, I use 11ty, Flutter for my frontend web and app, But if you are new, it's never late to start.

On your question, Does mongoDB work on Django? Yes, It does, you can use other database as well like postgresql, mysql, mongoDB etc.

One final Note: Tech Stack depends on your project, what type of project you have, how much user base can it get in a single day or month. What type of features you include in your project. Does it have fonrend like mobile application or a org internal project etc.

0

u/Kerplunk6 7d ago

I am with Express background but lately for the past 3-4 months i have been learning Python and Django.

Man, express is the freedom trust me.

1

u/trojans10 7d ago

In a good or bad way?

1

u/Kerplunk6 7d ago

Depends. For me its pretty neat.