Created
January 4, 2018 04:52
-
-
Save hsleonis/a2562f1d537045d3f9866fafec94ffcc to your computer and use it in GitHub Desktop.
Django initialize with app & admin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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 ../ | |
| cd %UserInputPath% | |
| 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment