Skip to content

Commit a9b307c

Browse files
committed
Upgrade to Django 1.9
1 parent 8b7bb90 commit a9b307c

14 files changed

+202
-223
lines changed

django-jquery-file-upload/settings.py

+70-124
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,95 @@
1+
"""
2+
Django settings.
3+
"""
4+
5+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16
import os
27

8+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9+
10+
# SECURITY WARNING: keep the secret key used in production secret!
11+
SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo'
12+
13+
# SECURITY WARNING: don't run with debug turned on in production!
314
DEBUG = True
4-
TEMPLATE_DEBUG = DEBUG
515

6-
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
16+
ALLOWED_HOSTS = []
17+
18+
# Application definition
719

8-
ADMINS = (
9-
# ('Your Name', 'your_email@example.com'),
20+
INSTALLED_APPS = (
21+
'fileupload.apps.FileuploadConfig',
22+
'django.contrib.admin',
23+
'django.contrib.auth',
24+
'django.contrib.contenttypes',
25+
'django.contrib.sessions',
26+
'django.contrib.messages',
27+
'django.contrib.staticfiles',
28+
)
29+
30+
MIDDLEWARE_CLASSES = (
31+
'django.contrib.sessions.middleware.SessionMiddleware',
32+
'django.middleware.common.CommonMiddleware',
33+
'django.middleware.csrf.CsrfViewMiddleware',
34+
'django.contrib.auth.middleware.AuthenticationMiddleware',
35+
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
36+
'django.contrib.messages.middleware.MessageMiddleware',
37+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
38+
'django.middleware.security.SecurityMiddleware',
1039
)
1140

12-
MANAGERS = ADMINS
41+
ROOT_URLCONF = 'django-jquery-file-upload.urls'
42+
43+
TEMPLATES = [
44+
{
45+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
46+
#'DIRS': ['django-jquery-file-upload/templates'],
47+
'APP_DIRS': True,
48+
'OPTIONS': {
49+
'context_processors': [
50+
'django.template.context_processors.debug',
51+
'django.template.context_processors.request',
52+
'django.contrib.auth.context_processors.auth',
53+
'django.contrib.messages.context_processors.messages',
54+
],
55+
},
56+
},
57+
]
58+
59+
WSGI_APPLICATION = 'django-jquery-file-upload.wsgi.application'
60+
61+
62+
# Database
63+
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
1364

1465
DATABASES = {
1566
'default': {
16-
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
17-
'NAME': os.path.join(SITE_ROOT, 'db'), # Or path to database file if using sqlite3.
18-
'USER': '', # Not used with sqlite3.
19-
'PASSWORD': '', # Not used with sqlite3.
20-
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
21-
'PORT': '', # Set to empty string for default. Not used with sqlite3.
67+
'ENGINE': 'django.db.backends.sqlite3',
68+
'NAME': os.path.join(BASE_DIR, 'db'),
2269
}
2370
}
2471

25-
# Local time zone for this installation. Choices can be found here:
26-
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
27-
# although not all choices may be available on all operating systems.
28-
# On Unix systems, a value of None will cause Django to use the same
29-
# timezone as the operating system.
30-
# If running in a Windows environment this must be set to the same as your
31-
# system time zone.
32-
TIME_ZONE = 'America/Chicago'
33-
34-
# Language code for this installation. All choices can be found here:
35-
# http://www.i18nguy.com/unicode/language-identifiers.html
72+
73+
# Internationalization
74+
# https://docs.djangoproject.com/en/1.8/topics/i18n/
75+
3676
LANGUAGE_CODE = 'en-us'
3777

38-
SITE_ID = 1
78+
TIME_ZONE = 'Europe/Oslo'
3979

40-
# If you set this to False, Django will make some optimizations so as not
41-
# to load the internationalization machinery.
4280
USE_I18N = True
4381

44-
# If you set this to False, Django will not format dates, numbers and
45-
# calendars according to the current locale
4682
USE_L10N = True
4783

48-
# Absolute filesystem path to the directory that will hold user-uploaded files.
49-
# Example: "/home/media/media.lawrence.com/media/"
50-
MEDIA_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/media/'
84+
USE_TZ = True
5185

52-
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
53-
# trailing slash.
54-
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
55-
MEDIA_URL = '/media/'
56-
57-
# Absolute path to the directory static files should be collected to.
58-
# Don't put anything in this directory yourself; store your static files
59-
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
60-
# Example: "/home/media/media.lawrence.com/static/"
61-
STATIC_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/static/'
6286

63-
# URL prefix for static files.
64-
# Example: "http://media.lawrence.com/static/"
87+
# Static files (CSS, JavaScript, Images)
6588
STATIC_URL = '/static/'
6689

67-
# URL prefix for admin static files -- CSS, JavaScript and images.
68-
# Make sure to use a trailing slash.
69-
# Examples: "http://foo.com/static/admin/", "/static/admin/".
70-
ADMIN_MEDIA_PREFIX = '/static/admin/'
71-
72-
# Additional locations of static files
73-
STATICFILES_DIRS = (
74-
# Put strings here, like "/home/html/static" or "C:/www/django/static".
75-
# Always use forward slashes, even on Windows.
76-
# Don't forget to use absolute paths, not relative paths.
77-
)
90+
STATICFILES_DIRS = [
91+
'django-jquery-file-upload/static',
92+
]
7893

79-
# List of finder classes that know how to find static files in
80-
# various locations.
81-
STATICFILES_FINDERS = (
82-
'django.contrib.staticfiles.finders.FileSystemFinder',
83-
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
84-
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
85-
)
86-
87-
# Make this unique, and don't share it with anybody.
88-
SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo'
89-
90-
# List of callables that know how to import templates from various sources.
91-
TEMPLATE_LOADERS = (
92-
'django.template.loaders.filesystem.Loader',
93-
'django.template.loaders.app_directories.Loader',
94-
# 'django.template.loaders.eggs.Loader',
95-
)
96-
97-
MIDDLEWARE_CLASSES = (
98-
'django.middleware.common.CommonMiddleware',
99-
'django.contrib.sessions.middleware.SessionMiddleware',
100-
'django.middleware.csrf.CsrfViewMiddleware',
101-
'django.contrib.auth.middleware.AuthenticationMiddleware',
102-
'django.contrib.messages.middleware.MessageMiddleware',
103-
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
104-
)
105-
106-
ROOT_URLCONF = 'django-jquery-file-upload.urls'
107-
108-
TEMPLATE_DIRS = (
109-
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
110-
# Always use forward slashes, even on Windows.
111-
# Don't forget to use absolute paths, not relative paths.
112-
)
113-
114-
INSTALLED_APPS = (
115-
'django.contrib.auth',
116-
'django.contrib.contenttypes',
117-
'django.contrib.sessions',
118-
'django.contrib.sites',
119-
'django.contrib.messages',
120-
'django.contrib.staticfiles',
121-
'fileupload',
122-
# Uncomment the next line to enable the admin:
123-
'django.contrib.admin',
124-
# Uncomment the next line to enable admin documentation:
125-
# 'django.contrib.admindocs',
126-
)
127-
128-
# A sample logging configuration. The only tangible logging
129-
# performed by this configuration is to send an email to
130-
# the site admins on every HTTP 500 error.
131-
# See http://docs.djangoproject.com/en/dev/topics/logging for
132-
# more details on how to customize your logging configuration.
133-
LOGGING = {
134-
'version': 1,
135-
'disable_existing_loggers': False,
136-
'handlers': {
137-
'mail_admins': {
138-
'level': 'ERROR',
139-
'class': 'django.utils.log.AdminEmailHandler'
140-
}
141-
},
142-
'loggers': {
143-
'django.request': {
144-
'handlers': ['mail_admins'],
145-
'level': 'ERROR',
146-
'propagate': True,
147-
},
148-
}
149-
}
94+
MEDIA_URL = '/media/'
95+
MEDIA_ROOT = os.path.join(BASE_DIR, 'django-jquery-file-upload', 'media')

django-jquery-file-upload/urls.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
from django.conf.urls import patterns, include, url
1+
from django.conf.urls import include, url
22
from django.http import HttpResponseRedirect
3+
from django.conf import settings
34

45
# Uncomment the next two lines to enable the admin:
56
from django.contrib import admin
67
admin.autodiscover()
78

8-
urlpatterns = patterns('',
9-
# Examples:
10-
# url(r'^$', 'upload.views.home', name='home'),
11-
9+
urlpatterns = [
1210
url(r'^$', lambda x: HttpResponseRedirect('/upload/new/')),
1311
url(r'^upload/', include('fileupload.urls')),
14-
15-
# Uncomment the admin/doc line below to enable admin documentation:
16-
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
17-
18-
# Uncomment the next line to enable the admin:
1912
url(r'^admin/', include(admin.site.urls)),
20-
)
13+
]
2114

22-
from os.path import join, abspath, dirname
23-
urlpatterns += patterns('',
24-
(r'^media/(.*)$', 'django.views.static.serve', {'document_root': join(abspath(dirname(__file__)), 'media')}),
25-
)
15+
if settings.DEBUG:
16+
from django.conf.urls.static import static
17+
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

django-jquery-file-upload/wsgi.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
WSGI config for django-jquery-file-upload project.
3+
"""
4+
5+
import os
6+
7+
from django.core.wsgi import get_wsgi_application
8+
9+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django-jquery-file-upload.settings")
10+
11+
application = get_wsgi_application()

fileupload/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class FileuploadConfig(AppConfig):
5+
name = 'fileupload'
6+

fileupload/migrations/0001_initial.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.6 on 2016-06-07 19:15
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='Picture',
18+
fields=[
19+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('file', models.ImageField(upload_to='pictures')),
21+
('slug', models.SlugField(blank=True)),
22+
],
23+
),
24+
]

fileupload/migrations/__init__.py

Whitespace-only changes.

fileupload/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Picture(models.Model):
1212
file = models.ImageField(upload_to="pictures")
1313
slug = models.SlugField(max_length=50, blank=True)
1414

15-
def __unicode__(self):
15+
def __str__(self):
1616
return self.file.name
1717

1818
@models.permalink

fileupload/templates/fileupload/picture_angular_form.html

+18-18
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
<!-- Bootstrap styles -->
2525
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
2626
<!-- Generic page styles -->
27-
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css">
27+
<link rel="stylesheet" href="/static/css/style.css">
2828
<!-- blueimp Gallery styles -->
29-
<link rel="stylesheet" href="{{ STATIC_URL }}css/blueimp-gallery.min.css">
29+
<link rel="stylesheet" href="/static/css/blueimp-gallery.min.css">
3030
<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
31-
<link rel="stylesheet" href="{{ STATIC_URL }}css/jquery.fileupload-ui.css">
31+
<link rel="stylesheet" href="/static/css/jquery.fileupload-ui.css">
3232
<!-- CSS adjustments for browsers with JavaScript disabled -->
33-
<noscript><link rel="stylesheet" href="{{ STATIC_URL }}css/jquery.fileupload-ui-noscript.css"></noscript>
33+
<noscript><link rel="stylesheet" href="/static/css/jquery.fileupload-ui-noscript.css"></noscript>
3434
<style>
3535
/* Hide Angular JS elements before initializing */
3636
.ng-cloak {
@@ -175,33 +175,33 @@ <h3 class="title"></h3>
175175
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
176176
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
177177
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
178-
<script src="{{ STATIC_URL }}js/vendor/jquery.ui.widget.js"></script>
178+
<script src="/static/js/vendor/jquery.ui.widget.js"></script>
179179
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
180-
<script src="{{ STATIC_URL }}js/load-image.min.js"></script>
180+
<script src="/static/js/load-image.min.js"></script>
181181
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
182-
<script src="{{ STATIC_URL }}js/canvas-to-blob.min.js"></script>
182+
<script src="/static/js/canvas-to-blob.min.js"></script>
183183
<!-- Bootstrap JS is not required, but included for the responsive demo navigation -->
184184
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
185185
<!-- blueimp Gallery script -->
186-
<script src="{{ STATIC_URL }}js/jquery.blueimp-gallery.min.js"></script>
186+
<script src="/static/js/jquery.blueimp-gallery.min.js"></script>
187187
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
188-
<script src="{{ STATIC_URL }}js/jquery.iframe-transport.js"></script>
188+
<script src="/static/js/jquery.iframe-transport.js"></script>
189189
<!-- The basic File Upload plugin -->
190-
<script src="{{ STATIC_URL }}js/jquery.fileupload.js"></script>
190+
<script src="/static/js/jquery.fileupload.js"></script>
191191
<!-- The File Upload processing plugin -->
192-
<script src="{{ STATIC_URL }}js/jquery.fileupload-process.js"></script>
192+
<script src="/static/js/jquery.fileupload-process.js"></script>
193193
<!-- The File Upload image preview & resize plugin -->
194-
<script src="{{ STATIC_URL }}js/jquery.fileupload-image.js"></script>
194+
<script src="/static/js/jquery.fileupload-image.js"></script>
195195
<!-- The File Upload audio preview plugin -->
196-
<script src="{{ STATIC_URL }}js/jquery.fileupload-audio.js"></script>
196+
<script src="/static/js/jquery.fileupload-audio.js"></script>
197197
<!-- The File Upload video preview plugin -->
198-
<script src="{{ STATIC_URL }}js/jquery.fileupload-video.js"></script>
198+
<script src="/static/js/jquery.fileupload-video.js"></script>
199199
<!-- The File Upload validation plugin -->
200-
<script src="{{ STATIC_URL }}js/jquery.fileupload-validate.js"></script>
200+
<script src="/static/js/jquery.fileupload-validate.js"></script>
201201
<!-- The File Upload Angular JS module -->
202-
<script src="{{ STATIC_URL }}js/jquery.fileupload-angular.js"></script>
202+
<script src="/static/js/jquery.fileupload-angular.js"></script>
203203
<!-- The main application script -->
204-
<script src="{{ STATIC_URL }}js/app.js"></script>
205-
<script src="{{ STATIC_URL }}js/csrf.js"></script>
204+
<script src="/static/js/app.js"></script>
205+
<script src="/static/js/csrf.js"></script>
206206
</body>
207207
</html>

0 commit comments

Comments
 (0)