Skip to content

Commit f74f7bd

Browse files
authored
Merge pull request #10 from suhailvs/master
updated django 3.x
2 parents 2dc5481 + 1f50f54 commit f74f7bd

File tree

11 files changed

+116
-63
lines changed

11 files changed

+116
-63
lines changed

demo/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Load the server
22
---------------
33

4-
* Create database: `python manage.py syncdb`
5-
* Load fixtures: `python manage.py loaddata <fixturename>`
4+
* Create database: `python manage.py migrate`
5+
* Load fixtures: `python manage.py loaddata publications`
66
* Run the server: `python manage.py runserver`

demo/app1/templates/home.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<head>
55
<title>Django-Selectize Basic example</title>
66
<!-- Bootstrap Theme CSS -->
7-
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
7+
<link href="https://getbootstrap.com/docs/4.6/dist/css/bootstrap.min.css" rel="stylesheet">
88

99
{% selectize_tags_media 'css' 'default' %}
10-
<link rel="stylesheet" href="http://highlightjs.org/static/styles/ir_black.css">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/tomorrow-night-blue.min.css">
1111
<style type="text/css">
1212
/*pre{background:#fff;color:#000;font-weight: 500;}*/
1313
body{background:#f1f1f1;}
@@ -146,7 +146,7 @@ <h3 class="text-muted">Django Selectize</h3>
146146
================================================== -->
147147
<!-- Placed at the end of the document so the pages load faster -->
148148
{% selectize_tags_media 'js' 'jquery' %}
149-
<script src="http://highlightjs.org/static/highlight.pack.js"></script>
149+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
150150

151151
<script>
152152
$('#select-country').selectize();

demo/app1/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from django.conf.urls import url
2-
from app1.views import ArticleAdd,ArticleUpdate
31

2+
from app1.views import ArticleAdd,ArticleUpdate
3+
from django.urls import path
44
urlpatterns = [
5-
url(r'^articles/add/$', ArticleAdd.as_view(),name='articles'),
6-
url(r'^articles/(?P<pk>[0-9]+)/$', ArticleUpdate.as_view(), name='article_update'),
5+
path('articles/add/', ArticleAdd.as_view(),name='articles'),
6+
path('articles/(?P<pk>[0-9]+)/', ArticleUpdate.as_view(), name='article_update'),
77
]

demo/app1/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.shortcuts import render
22
from django.views.generic.edit import CreateView,UpdateView
3-
from django.core.urlresolvers import reverse_lazy
3+
from django.urls import reverse_lazy
44
#from django.core.urlresolvers import reverse
55
from app1.models import Article
66
# Create your views here.

demo/demo/asgi.py

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

demo/demo/settings.py

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
"""
22
Django settings for demo project.
33
4+
Generated by 'django-admin startproject' using Django 3.2.8.
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/3.2/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/3.2/ref/settings/
911
"""
1012

11-
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12-
import os
13-
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
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/3.2/howto/deployment/checklist/
1821

1922
# SECURITY WARNING: keep the secret key used in production secret!
20-
SECRET_KEY = 'h)j4s86=tu$69r(sgmhb--#fpt6-c-d66cqu8^_#i$3#!h^o%d'
23+
SECRET_KEY = 'django-insecure-gwlh_ig2u0y)+(hs=y00e9^i=921d^rh#_6urrk10h=-y&%8ua'
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,35 +39,71 @@
3839
'django.contrib.staticfiles',
3940
'selectize',
4041
'app1',
42+
]
4143

42-
)
43-
44-
MIDDLEWARE_CLASSES = (
44+
MIDDLEWARE = [
45+
'django.middleware.security.SecurityMiddleware',
4546
'django.contrib.sessions.middleware.SessionMiddleware',
4647
'django.middleware.common.CommonMiddleware',
4748
'django.middleware.csrf.CsrfViewMiddleware',
4849
'django.contrib.auth.middleware.AuthenticationMiddleware',
4950
'django.contrib.messages.middleware.MessageMiddleware',
5051
'django.middleware.clickjacking.XFrameOptionsMiddleware',
51-
)
52+
]
5253

5354
ROOT_URLCONF = 'demo.urls'
5455

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

5774

5875
# Database
59-
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
76+
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
6077

6178
DATABASES = {
6279
'default': {
6380
'ENGINE': 'django.db.backends.sqlite3',
64-
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
81+
'NAME': BASE_DIR / 'db.sqlite3',
6582
}
6683
}
6784

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

71108
LANGUAGE_CODE = 'en-us'
72109

@@ -80,6 +117,11 @@
80117

81118

82119
# Static files (CSS, JavaScript, Images)
83-
# https://docs.djangoproject.com/en/1.6/howto/static-files/
120+
# https://docs.djangoproject.com/en/3.2/howto/static-files/
84121

85122
STATIC_URL = '/static/'
123+
124+
# Default primary key field type
125+
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
126+
127+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

demo/demo/urls.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from django.conf.urls import patterns, include, url
1+
2+
from django.urls import include, path
23
from django.views.generic import TemplateView
34
from django.contrib import admin
4-
admin.autodiscover()
55

6-
urlpatterns = patterns('',
6+
7+
urlpatterns = [
78
# Examples:
8-
url(r'^$',TemplateView.as_view(template_name="home.html"), name='home'),
9-
url(r'^tests/', include('app1.urls')),
10-
url(r'^admin/', include(admin.site.urls)),
11-
)
9+
path('', TemplateView.as_view(template_name="home.html"), name='home'),
10+
path('tests/', include('app1.urls')),
11+
path('admin/', admin.site.urls),
12+
]

demo/demo/wsgi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
88
"""
99

1010
import os
11-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
1211

1312
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')
15+
1416
application = get_wsgi_application()

demo/fixtures.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

demo/manage.py

100644100755
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
23
import os
34
import sys
45

5-
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
7-
SELECTIZE_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
8-
sys.path.append(SELECTIZE_PATH)
9-
from django.core.management import execute_from_command_line
106

11-
execute_from_command_line(sys.argv)
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

selectize/templatetags/selectize_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django import template
22
# from django.templatetags.static import static
33
# see stackoverflow :http://stackoverflow.com/questions/11721818
4-
from django.contrib.staticfiles.templatetags.staticfiles import static
4+
from django.templatetags.static import static
55
from django.utils.safestring import mark_safe
66

77
register = template.Library()

0 commit comments

Comments
 (0)