Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
TICKET_STATUS_OPEN = 1
TICKET_STATUS_CLOSE = 2
TICKET_STATUS_DEPRECATED = 3
TICKET_STATUS_TRASH = 4
TICKET_STATUSES = (
(TICKET_STATUS_OPEN, 'OPEN'),
(TICKET_STATUS_CLOSE, 'CLOSE'),
(TICKET_STATUS_DEPRECATED, 'DEPRECATED'),
(TICKET_STATUS_TRASH, 'TRASH'),
)
title = models.CharField(max_length=100)
status = models.PositiveIntegerField(max_length=2, choices=TICKET_STATUSES, default=TICKET_STATUS_OPEN)
send_mail(subject, message, phone, ['myemail@mail.ru'], recepients)
send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, html_message=None)
user = models.OneToOneField(User)
count = models.ManyToManyField(Article)
название поля не отвечает содержимомуsudo apt-get install postgresql-server-dev-9.3 python3-dev
libpq-dev
Description: header files for libpq5 (PostgreSQL library)
Header files and static library for compiling C programs to link with the libpq library in
order to communicate with a PostgreSQL database backend.
sudo apt-get install libpq-dev python3-dev
разнести настройки "по категориям"Никогда такой надобности не было
foo='bar'
from settings1.py import *
зависимости от environment, например, db.py разный для prod\dev\test
myprog
├── manage.py
└── myprog
├── __init__.py
├── settings
│ ├── __init__.py
│ ├── global.py
│ └── settings_test.py
├── urls.py
└── wsgi.py
import os
if os.environ['test']:
from settings_test.py import *
# common settings for all env types
from global.py import *
foo='buzz'
{% load static %}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>{{ page_title }}</title>
<link rel="stylesheet" href="{% static "css/main.css" %}">
<link rel="shortcut icon" type="image/png" href="{% static "favicon.ico" %}">
....