Обращаю внимание на урок 8, там показан процесс в течение 20-ти минут, от создания проекта до первой страницы.
Это не обучение, там нет объяснений. Урок записан для людей, которые никогда не сталкивались с Django.
Просто, что бы они посмотрели, что такое писать на Django.
В школе всё разбирается подробно.
settings.py
"""
Django settings for untit project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'de+oz889^^7iz%b^c#8mxol1##dsovnv*y81*o%gmlb50l^m1+'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'saas',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'untit.urls'
WSGI_APPLICATION = 'untit.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'ru-ru'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'E:/django_projects/untit/saas/static/'
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
'E:/django_projects/untit/saas/template/'
)
models.py
from django.db import models
class Saas(models.Model):
title = models.CharField(max_length=128)
text = models.TextField(blank=True)
def __unicode__(self):
return self.title
views.py
from django.shortcuts import render, render_to_response
from saas.models import Saas
def saas_all(request):
to = Saas.objects.all()
return render_to_response ('saas.html', {'to':to})
urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'untit.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^saas/', include('saas.urls')),
url(r'^admin/', include(admin.site.urls)),
)
saas/urls.py
# -*- coding: utf-8 -*-
__author__ = 'admin'
from django.conf.urls import patterns, url
from saas.views import saas_all
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'untit.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^$', saas_all ),
)
base.html
Я главный
{% block saas %}{% endblock %}
template/saas.html
{% extends 'base.html' %}
{% block saas %}
{% for i in to %}
{{ i.title }}
{{ i.text }}
{% endfor %}
{% endblock %}