# clone repo
git clone https://github.com/pahaz/django_test1.git my-first-project-name
cd my-first-project-name
# install virtualenv
pip install virtualenv # easy_install virtualenv
# make virtualenv
virtualenv venv
# activate venv
venv\Scripts\activate # windows
. venv/bin/activate # Linux, OS X
# install requirements
pip install -r requirements.txt
# create db
python manage.py migrate
# run server
python manage.py runserver_plus
virtualenv .venv
, activate,pip install -r requirements.txt
python manage.py startproject
- project structure (
manage.py
,_project_v1_
,_project_v1_/settings.py
,_project_v1_/wsgi.py
,_project_v1_/urls.py
) python manage.py runserver
- project settings (
DEBUG
,INSTALLED_APPS
,ROOT_URLCONF
,WSGI_APPLICATION
,DATABASES
,TEMPLATES
,TEMPLATES['DIRS']
) - write simple view
def index(request): return render(request, 'index.html')
inurls.py
- add
_project_v1_/templates/index.html
, change settingsTEMPLATES['DIRS']
- install
django_debug_toolbar>=1.3.0
,django_extensions>=1.5.2
, add toINSTALLED_APPS
- show
debug-toolbar
features - show
python manage.py runserver_plus
- add static file
_project_v1_/static/robots.txt
, change settingsSTATICFILES_DIRS
; tell about how to django gives static files,'django.contrib.staticfiles'
- show django admin interface; tell about User, Group, Permission models; overview of
INSTALLED_APPS
- tell about ORM, migrations
python manage.py startapp
- app structure (
models.py
,migrations
,views.py
,tests.py
,admin.py
) - write simple
Model
(class Entry(models.Model): title = models.CharField(max_length=200)
) python manage.py help
python manage.py makemigrations
, showmigrations/0001_initial.py
python manage.py migrate
- show
db.sqlite3
file (sqlite3 view) python manage.py shell
,python manage.py shell_plus
- create models and show in
db.sqlite3
file - show models API, tell about
Manager
- write model with
ForeignKey
,ManyToManyField
andDateTimeField
(Entry
with author andTags
) - show
python manage.py makemigrations
and tell about the new columns default values; showmigrations/0002_auto*.py
- show more model API; tell about
.save()
related objects - show how to write simple script for work with
models.py
(os.environ.setdefault("DJANGO_SETTINGS_MODULE", "_project_v1_.settings"); from django.conf import settings
)
- write
view.py