Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to code a batch file to automate django web server start

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

like image 273
Spikie Avatar asked Jun 12 '10 01:06

Spikie


People also ask

What is the command to start the Django built in development server?

python manage.py runserver The runserver command is a built-in subcommand of Django's manage.py file that will start up a development server for this specific Django project.

How do I run a batch file from a website?

Just create a batch file and save in the location where your html file is there. this anchor tag will execute the (test. bat) batch file. After clicking on the link <TEST>, you will get the window prompting to open/save/close, if you will click on open then batch file will be executed.


3 Answers

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.

like image 193
Miguel Ventura Avatar answered Sep 25 '22 13:09

Miguel Ventura


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?

like image 35
Ankit Jaiswal Avatar answered Sep 26 '22 13:09

Ankit Jaiswal


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.
like image 29
Abu Shumon Avatar answered Sep 25 '22 13:09

Abu Shumon