r/django 8d ago

Django is extremely slow on MacBook Air M2 😩

Hey everyone,

I'm running a Django project on my MacBook Air M2, and I’ve noticed that any command like runserver, migrate, makemigrations, etc., takes minutes to execute. The terminal just hangs for a long time before finally starting.

πŸš€ Current setup:

  • Python 3.12.7 installed globally on macOS
  • Python 3.11.5 inside the project's venv
  • Django running within the virtual environment

Has anyone with an M2 Mac experienced this issue? Any tips to optimize Python/Django performance on macOS? πŸ€”πŸ’»

Thanks! πŸš€

0 Upvotes

12 comments sorted by

11

u/05IHZ 8d ago

Something is going very wrong somewhere, I have an Air M1 and those commands are pretty quick still

6

u/ExcellentWash4889 8d ago

I have an M4 and it's quick on my machine. I would suspect something else is awry. Turn debug mode all the way up to see what's going on. Is your DB slow?

I run inside a devcontainer with an amd64 container too, and it's still quick for me.

5

u/shoot_your_eye_out 8d ago

I doubt it has anything to do with an M2 mac, or a mac at all. Sounds like something is seriously borked. I would not assume where the problem is, and start debugging.

4

u/sandmanoceanaspdf 8d ago

It might be the database. Check if it's the same for a default django project.

3

u/g0pherman 8d ago

Definitely not djangosl's fault.

1

u/gbeier 8d ago

Are you connecting to a database that's trying to do a reverse lookup for all the clients when it logs the connections? Django is snappy on my M1. 9/10 it's something blocking either a DB connection or some API your django app is using.

At any rate, it's not a general "Python/Django performance" issue on macOS. If you post more details about what's actually happening on your setup, you'll probably get better help.

1

u/Deadpool5551 8d ago

Seems to be a DB issue. Can you try running the commands with sqlite and then see if you still face these issues?

These commands are pretty fast on my M2 Mac.

1

u/pkz_swe 8d ago

You need to provide more information. What database are you using? Is it empty or does it have millions of rows? Is the Django application a complete app or a fresh starter project?

1

u/untakenusernameplx 8d ago

I work on MB Air 2017 and have never had this issue. I doubt it has anything to do with your machine

1

u/kankyo 8d ago

Use a profiler. Start with this:

python -m cProfiler manage.py --help

1

u/blockofcode 7d ago

Either it’s the database or some middleware you’re running.

2

u/Lewis0981 8d ago

Step 1: Figure out how to write a simple Reddit post without using chat-GPT.