Home > database >  How do I run an existing Django file?
How do I run an existing Django file?

Time:07-02

I downloaded a folder with multiple python files in the form of a Django project for a course and I am unable to run it. Usually, when you create a Django project it is created within the terminal with the line django-admin startproject web_project . and then python manage.py migrate is used and then the line python manage.py runserver to start a server.

How do I start a server to run my project?

When I use django-admin startproject web_project ., it creates a new project which I don't want. When I use python manage.py migrate or python manage.py runserver it says:

Command 'python' not found, did you mean:

  command 'python3' from deb python3
  command 'python' from deb python-is-python3

But even when I used python3 manage.py migrate or python3 manage.py runserver instead and it returned:

python3: can't open file 'manage.py': [Errno 2] No such file or directory

CodePudding user response:

first of all I recommend creating a virtual environment using the following command

python3 -m venv .env

then activate it source .env/bin/activate "django-admin statproject" its for initalite a new project for running an excited Django app you should just install Django - if there is now "requirements.txt" file- , migrate and run.

pip install Django
python manage.py migrate
python manage.py runserver

CodePudding user response:

At first make sure you opened command prompt or terminal in right directory(in projects directory) when you are running the runserver command. If you are on windows open the project folder(the folder that contains files like manage.py), then right click and press open PowerShell window here.

  • Related