Skip to content

Commit

Permalink
Fix/migrate to django4 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
aciddust authored Dec 29, 2021
1 parent 243594f commit e6ec94f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
16 changes: 16 additions & 0 deletions djangosample/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for djangosample project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangosample.settings')

application = get_asgi_application()
21 changes: 13 additions & 8 deletions djangosample/settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Django settings for djangosample project.
Generated by 'django-admin startproject' using Django 1.10.6.
Generated by 'django-admin startproject' using Django 4.0.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

import os
Expand All @@ -17,7 +17,7 @@


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '7ngkdjajhzi2oi+6izsv+!hg5lhdhzb0(d8d(qv11$i=)14n*)')
Expand Down Expand Up @@ -71,7 +71,7 @@


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
'default': {
Expand All @@ -86,7 +86,7 @@


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -105,7 +105,7 @@


# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
# https://docs.djangoproject.com/en/4.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -119,10 +119,15 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = '/app/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

if DEBUG:
ALLOWED_HOSTS += ['*', ]
14 changes: 7 additions & 7 deletions djangosample/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""djangosample URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
2. Add a URL to urlpatterns: path('', 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')
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.urls import re_path
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
re_path(r'^admin/', admin.site.urls),
]
2 changes: 1 addition & 1 deletion djangosample/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""

import os
Expand Down
19 changes: 6 additions & 13 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangosample.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

0 comments on commit e6ec94f

Please sign in to comment.