2

I am new to python and django i am creating first tutorial app.

I created app file using following command:

C:\Python27\Scripts\django-admin.py startproject mysite

After that successfully created a file in directory

But how to run python manage.py runserver i am getting error not recognized as an internal or extrnal command

C:\Python27\Scripts\django-admin.py startproject mysite

But how to run python manage.py runserver i am getting error not recognized as an internal or extrnal command

2 Answers 2

3

You just need to cd into mysite from there.

Use cd mysite from the command line. Then run python manage.py runserver and the dev server will startup in the current (or a new if there inst a current) browser window.

To visualize this for you:

current_dir/ <-- your here now
        mysite/      < -- use cd mysite to get to here!
             manage.py  <-- and use this
             mysite/   
                    __init__.py
                    urs.py
                    settings.py
                    ect.

current_dir is where you initially created the project.

Pro tip: you always have to come back to this exact dir to use manage.py, so if you get that error again while your making the polls app; you are probably just in the wrong directory.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to go to the directory that the app you created resides in then run the command manage.py runserver on windows or python manage.py runserver in a Unix Terminal.

It is typical to create a separate directory for your Django projects. A typical directory would be:

C:\DjangoProjects\

You would then put the location of django-admin.py on your PYTHONPATH in your command shell and run the startproject command and the new project would be created in the current directory that you are in. If you have already created the project, you could also just cut and paste it to a different directory that way your Django projects are not in the same directory as your Python / Django source code.

Either way, in the end go the directory for the app you created, so:

C:\DjangoProjects\mysite\

and from that directory run the manage.py runserver command and this will start the app running on your local machine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.