Skip to content

Commit 9a6bfc7

Browse files
committed
Upgrade testproj to Django 1.9
1 parent e66d4fd commit 9a6bfc7

File tree

9 files changed

+125
-40
lines changed

9 files changed

+125
-40
lines changed

testproj/README

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
1. Create a virtualenv
2-
2. pip install django webstack_django_sorting
3-
3. ./manage.py syncdb
4-
4. ./manage.py runserver
1+
1. Create a virtualenv (mkvirtualenv)
2+
2. pip install -r requirements.txt
3+
3 pip install -e ..
4+
4. ./manage.py migrate
5+
5. ./manage.py loaddata secretfiles
6+
6. ./manage.py runserver

testproj/manage.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44

55
if __name__ == "__main__":
66
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproj.settings")
7-
8-
from django.core.management import execute_from_command_line
9-
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError:
10+
# The above import may fail for some other reason. Ensure that the
11+
# issue is really that Django is missing to avoid masking other
12+
# exceptions on Python 2.
13+
try:
14+
import django
15+
except ImportError:
16+
raise ImportError(
17+
"Couldn't import Django. Are you sure it's installed and "
18+
"available on your PYTHONPATH environment variable? Did you "
19+
"forget to activate a virtual environment?"
20+
)
21+
raise
1022
execute_from_command_line(sys.argv)

testproj/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Django==1.9

testproj/testproj/settings.py

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
"""
22
Django settings for testproj project.
33
4+
Generated by 'django-admin startproject' using Django 1.10.4.
5+
46
For more information on this file, see
5-
https://docs.djangoproject.com/en/1.6/topics/settings/
7+
https://docs.djangoproject.com/en/1.10/topics/settings/
68
79
For the full list of settings and their values, see
8-
https://docs.djangoproject.com/en/1.6/ref/settings/
10+
https://docs.djangoproject.com/en/1.10/ref/settings/
911
"""
1012

11-
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1213
import os
13-
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1417

1518

1619
# Quick-start development settings - unsuitable for production
17-
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
1821

1922
# SECURITY WARNING: keep the secret key used in production secret!
20-
SECRET_KEY = 'n(z9(=frn3$o5__2=v-cvv&hnoy_t*$evfv@64edcr=gl0grl9'
23+
SECRET_KEY = '&vdbp^iy*81zng0*1l&#q7px983y&g6^)=!+r&!!alvq6cxy6='
2124

2225
# SECURITY WARNING: don't run with debug turned on in production!
2326
DEBUG = True
2427

25-
TEMPLATE_DEBUG = True
26-
2728
ALLOWED_HOSTS = []
2829

2930

3031
# Application definition
3132

32-
INSTALLED_APPS = (
33+
INSTALLED_APPS = [
3334
'django.contrib.admin',
3435
'django.contrib.auth',
3536
'django.contrib.contenttypes',
@@ -38,36 +39,42 @@
3839
'django.contrib.staticfiles',
3940
'testproj.testapp',
4041
'webstack_django_sorting',
41-
)
42+
]
4243

43-
MIDDLEWARE_CLASSES = (
44+
MIDDLEWARE_CLASSES = [
45+
'django.middleware.security.SecurityMiddleware',
4446
'django.contrib.sessions.middleware.SessionMiddleware',
4547
'django.middleware.common.CommonMiddleware',
4648
'django.middleware.csrf.CsrfViewMiddleware',
4749
'django.contrib.auth.middleware.AuthenticationMiddleware',
4850
'django.contrib.messages.middleware.MessageMiddleware',
4951
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5052
'webstack_django_sorting.middleware.SortingMiddleware',
51-
)
52-
53-
TEMPLATE_CONTEXT_PROCESSORS = (
54-
'django.contrib.auth.context_processors.auth',
55-
'django.core.context_processors.debug',
56-
'django.core.context_processors.i18n',
57-
'django.core.context_processors.media',
58-
'django.core.context_processors.static',
59-
'django.core.context_processors.tz',
60-
'django.core.context_processors.request',
61-
'django.contrib.messages.context_processors.messages',
62-
)
53+
]
6354

6455
ROOT_URLCONF = 'testproj.urls'
6556

57+
TEMPLATES = [
58+
{
59+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
60+
'DIRS': [],
61+
'APP_DIRS': True,
62+
'OPTIONS': {
63+
'context_processors': [
64+
'django.template.context_processors.debug',
65+
'django.template.context_processors.request',
66+
'django.contrib.auth.context_processors.auth',
67+
'django.contrib.messages.context_processors.messages',
68+
],
69+
},
70+
},
71+
]
72+
6673
WSGI_APPLICATION = 'testproj.wsgi.application'
6774

6875

6976
# Database
70-
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
77+
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
7178

7279
DATABASES = {
7380
'default': {
@@ -76,8 +83,28 @@
7683
}
7784
}
7885

86+
87+
# Password validation
88+
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
89+
90+
AUTH_PASSWORD_VALIDATORS = [
91+
{
92+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
93+
},
94+
{
95+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
96+
},
97+
{
98+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
99+
},
100+
{
101+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
102+
},
103+
]
104+
105+
79106
# Internationalization
80-
# https://docs.djangoproject.com/en/1.6/topics/i18n/
107+
# https://docs.djangoproject.com/en/1.10/topics/i18n/
81108

82109
LANGUAGE_CODE = 'en-us'
83110

@@ -91,7 +118,7 @@
91118

92119

93120
# Static files (CSS, JavaScript, Images)
94-
# https://docs.djangoproject.com/en/1.6/howto/static-files/
121+
# https://docs.djangoproject.com/en/1.10/howto/static-files/
95122

96123
STATIC_URL = '/static/'
97124

File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9 on 2016-12-08 17:52
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.utils.timezone
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
initial = True
12+
13+
dependencies = [
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='SecretFile',
19+
fields=[
20+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('filename', models.CharField(blank=True, max_length=255, null=True)),
22+
('order', models.IntegerField(blank=True, null=True)),
23+
('size', models.PositiveIntegerField(blank=True, null=True)),
24+
('created_on', models.DateTimeField(default=django.utils.timezone.now)),
25+
('is_secret', models.BooleanField(default=False)),
26+
],
27+
),
28+
]

testproj/testproj/testapp/migrations/__init__.py

Whitespace-only changes.

testproj/testproj/urls.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from django.conf.urls import patterns, include, url
1+
from django.conf.urls import url
22
from django.contrib import admin
3+
from testproj.testapp import views
34

4-
admin.autodiscover()
5-
6-
urlpatterns = patterns('',
7-
url(r'^$', 'testproj.testapp.views.test_index'),
8-
url(r'^admin/', include(admin.site.urls)),
9-
)
5+
urlpatterns = [
6+
url(r'^$', views.test_index),
7+
url(r'^admin/', admin.site.urls),
8+
]

testproj/testproj/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for testproj project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproj.settings")
15+
16+
application = get_wsgi_application()

0 commit comments

Comments
 (0)