Ask coding questions

← Back to all posts
Why am I getting no such file:main.py error?
SUHASTADIPARTH1 (191)

Hi, I am trying to build a project in django, but I am getting a no such file: main.py error?

Could you please help me? I don't have a file called main.py

and also, when I close out of my django repls, and when I come back, they are not being saved at all!
Could you also help me with this? Thank you
This problem happens to all my django projects

Comments
hotnewtop
Coder100 (18934)

Create a .replit file to configure what python runs.
As you may know, django doesn't use main.py, it uses a more cli-based python file.

SUHASTADIPARTH1 (191)

@Coder100 repl it automatically creates a .replit file when creating a django repl.

MrVoo (102)

Try adding a main.py but keep it empty

SUHASTADIPARTH1 (191)

@MrVoo then my django project doesn't even run!

MrVoo (102)

@SUHASTADIPARTH1 Try importing the managae file then

SUHASTADIPARTH1 (191)

@MrVoo um, could you please explain what you mean?

MrVoo (102)

@SUHASTADIPARTH1 Okkaaay, delete the main.py and just change the run="" in .replit to run="manage.py"

SUHASTADIPARTH1 (191)

@MrVoo well technically, if i just click on .replit file, the django project runs, but the problem is that, I would have to do it for all my future projects. Previously, i didn't do this. Once everything was installed, it worked perfectly. But right now, I am not sure why repl it is having this problem!

SUHASTADIPARTH1 (191)

@MrVoo and also, whenever you're running django, you have to specify runserver, but I will still try your suggestion!

SUHASTADIPARTH1 (191)

@MrVoo Yup, It doesn't work. It just lists out some commands

SUHASTADIPARTH1 (191)

@MrVoo yes, I did. But like I said, if I just go into that file, it works. And it did. But how to get rid of that error. It happens every time I open my django project?