Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Last active November 14, 2017 06:49
Show Gist options
  • Select an option

  • Save hsleonis/a359661492d5fcbd145a81ddd984f773 to your computer and use it in GitHub Desktop.

Select an option

Save hsleonis/a359661492d5fcbd145a81ddd984f773 to your computer and use it in GitHub Desktop.
Generate basic django project on windows
@echo off
set /p UserInputPath= Enter directory name :
:: mkdir %UserInputPath%
:: mkvirtualenv biman
:: workon biman
:: pip install django
:: pip install django-admin
django-admin startproject %UserInputPath%
cd %UserInputPath%
set /p UserAppPath= Enter app name :
python manage.py startapp %UserAppPath%
:: break>"test.txt"
:: app view
echo from django.http import HttpResponse > %UserAppPath%"/views.py"
echo def index(request): >> %UserAppPath%"/views.py"
echo return HttpResponse("Hello, world. You're at the index.") >> %UserAppPath%"/views.py"
:: app URLs
echo from django.conf.urls import url > %UserAppPath%"/urls.py"
echo from . import views >> %UserAppPath%"/urls.py"
echo urlpatterns = [ >> %UserAppPath%"/urls.py"
echo url(r'^^$', views.index, name='index'), >> %UserAppPath%"/urls.py"
echo ] >> %UserAppPath%"/urls.py"
:: site URLs
cd ../
echo from django.conf.urls import include, url > %UserInputPath%"/urls.py"
echo from django.contrib import admin >> %UserInputPath%"/urls.py"
echo urlpatterns = [ >> %UserInputPath%"/urls.py"
echo url(r'^^%UserAppPath%/', include('%UserAppPath%.urls')), >> %UserInputPath%"/urls.py"
echo url(r'^^admin/', admin.site.urls), >> %UserInputPath%"/urls.py"
echo ] >> %UserInputPath%"/urls.py"
pause>null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment