# 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
, function based views (FBV), good for read and understand, docorator concept. - write
urls.py
, urlinclude
Form
,ModelForm
,Widget
, form in templates,csrf_token
,clean()
- simple
admin.py
,admin.site.register
- settings
LANGUAGE_CODE
,TIME_ZONE
- rewrite
view.py
, class based views (CBV), [https://ccbv.co.uk/], bad for understand, mixin concept. request.user
,AnonymousUser
- more
admin.py
(https://github.com/pahaz/django-steps/blob/master/_step_06/complaints/admin.py#L7-L26) - tell about override app logic
- templates override (https://github.com/pahaz/django-steps/blob/master/_step_06/complaints/templates/complaints/index.html / https://github.com/pahaz/django-steps/blob/master/_step_06/_project_v6_/templates/complaints/index.html)
- templates tags/filters (https://github.com/pahaz/django-steps/blob/master/_step_06/complaints/templatetags/complaints_tags.py#L7-L54)
- template context processors (https://github.com/pahaz/django-steps/blob/master/_step_06/complaints/context_processors.py)
- overrides: urls, view (decorator, mixin)
-
tell how django processes a request: https://docs.djangoproject.com/en/dev/_images/middleware.svg
-
ModelManager as single point to model API (https://github.com/pahaz/django-steps/blob/master/_step_07/complaints/models.py#L6-L30)
-
Abstract models
-
python manage.py squashmigrations
-
inline admin! https://github.com/pahaz/django-steps/blob/master/_step_08/complaints/admin.py#L10-L13
-
work with media data! https://github.com/pahaz/django-steps/tree/master/_step_08
-
write tests! tutorial05.html