5

i really need a code sample to automate starting Django development webserver "python manage.py runserver" in a .bat file in windows . I have python26 and django 1.1.1 in installed

Thanks

i meant by automate is clicking on the .bat file and the Django development webserver start up and i have no batch file scripting knowledge will love to get a code sample

Spikie
  • 389
  • 2
  • 8
  • 21

3 Answers3

10

You can write a .bat file containing:

cd <location of your django project>
<location of python.exe> manage.py runserver

I believe that should suffice.

Miguel Ventura
  • 10,344
  • 2
  • 31
  • 41
  • The code is just like that... all you have to do is replace what's inside the <>s. Location of python.exe should be something like `"C:\Program Files\Python\python-2.6.1\python.exe"` but will depend on your installation. Similarly, django project location is the folder where your django project is. – Miguel Ventura Jun 12 '10 at 13:56
  • how can i do this in ubuntu? – Shift 'n Tab Sep 29 '16 at 06:01
2

Miguel and Ankit already answered you. I just followed it and it worked. Here is my complete offeronline.bat

D:
cd user\shumon\offeronline 
manage.py runserver

My Django project and python files are in the D drive.

  • D: changes the current directory to D
  • the next command cd ... changes the current directory to the exact location of the project.
  • manage.py runserver runs the server.
jrouquie
  • 4,315
  • 4
  • 27
  • 43
Abu Shumon
  • 1,834
  • 22
  • 36
2

As Miguel said, you can write the below lines:

cd <location of your django project>

<location of python.exe> manage.py runserver

in a file and save it as somefilename.bat, thats it. Now, its a batch file and clicking on it would execute it i.e. your runserver command.

What do you mean by batch file scripting?

Ankit Jaiswal
  • 743
  • 2
  • 7
  • 10