mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-29 13:04:05 +03:00
Migrate to Django2 path urls (#1637)
* Change users urls to Django 2 paths * Change config urls to Django 2 paths * Change admin url setting to Django 2 path syntax * Replace more admin urls * Add myself to contributors.rst
This commit is contained in:
parent
fd15b20a08
commit
6d4be405d8
|
@ -141,6 +141,7 @@ Listed in alphabetical order.
|
||||||
Roman Afanaskin `@siauPatrick`_
|
Roman Afanaskin `@siauPatrick`_
|
||||||
Roman Osipenko `@romanosipenko`_
|
Roman Osipenko `@romanosipenko`_
|
||||||
Russell Davies
|
Russell Davies
|
||||||
|
Sascha `@saschalalala` @saschalalala
|
||||||
Sam Collins `@MightySCollins`_
|
Sam Collins `@MightySCollins`_
|
||||||
Shupeyko Nikita `@webyneter`_
|
Shupeyko Nikita `@webyneter`_
|
||||||
Sławek Ehlert `@slafs`_
|
Sławek Ehlert `@slafs`_
|
||||||
|
|
|
@ -18,7 +18,7 @@ Run these commands to deploy the project to Heroku:
|
||||||
|
|
||||||
heroku config:set WEB_CONCURRENCY=4
|
heroku config:set WEB_CONCURRENCY=4
|
||||||
# Generating a 32 character-long random string without any of the visually similiar characters "IOl01":
|
# Generating a 32 character-long random string without any of the visually similiar characters "IOl01":
|
||||||
heroku config:set DJANGO_ADMIN_URL="^$(openssl rand -base64 4096 | tr -dc 'A-HJ-NP-Za-km-z2-9' | head -c 32)/"
|
heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 4096 | tr -dc 'A-HJ-NP-Za-km-z2-9' | head -c 32)/"
|
||||||
heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)"
|
heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)"
|
||||||
heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production
|
heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production
|
||||||
heroku config:set DJANGO_ALLOWED_HOSTS='.herokuapp.com'
|
heroku config:set DJANGO_ALLOWED_HOSTS='.herokuapp.com'
|
||||||
|
|
|
@ -18,7 +18,7 @@ DJANGO_READ_DOT_ENV_FILE READ_DOT_ENV_FILE False
|
||||||
======================================= =========================== ============================================== ======================================================================
|
======================================= =========================== ============================================== ======================================================================
|
||||||
Environment Variable Django Setting Development Default Production Default
|
Environment Variable Django Setting Development Default Production Default
|
||||||
======================================= =========================== ============================================== ======================================================================
|
======================================= =========================== ============================================== ======================================================================
|
||||||
DJANGO_ADMIN_URL n/a r'^admin/' raises error
|
DJANGO_ADMIN_URL n/a 'admin/' raises error
|
||||||
DJANGO_CACHES CACHES (default) locmem redis
|
DJANGO_CACHES CACHES (default) locmem redis
|
||||||
DJANGO_DATABASES DATABASES (default) See code See code
|
DJANGO_DATABASES DATABASES (default) See code See code
|
||||||
DJANGO_DEBUG DEBUG True False
|
DJANGO_DEBUG DEBUG True False
|
||||||
|
|
|
@ -154,7 +154,7 @@ def set_django_admin_url(file_path):
|
||||||
django_admin_url = set_flag(
|
django_admin_url = set_flag(
|
||||||
file_path,
|
file_path,
|
||||||
"!!!SET DJANGO_ADMIN_URL!!!",
|
"!!!SET DJANGO_ADMIN_URL!!!",
|
||||||
formatted="^{}/",
|
formatted="{}/",
|
||||||
length=32,
|
length=32,
|
||||||
using_digits=True,
|
using_digits=True,
|
||||||
using_ascii_letters=True,
|
using_ascii_letters=True,
|
||||||
|
|
|
@ -216,8 +216,8 @@ EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.s
|
||||||
|
|
||||||
# ADMIN
|
# ADMIN
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Django Admin URL regex.
|
# Django Admin URL.
|
||||||
ADMIN_URL = r'^admin/'
|
ADMIN_URL = 'admin/'
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
||||||
ADMINS = [
|
ADMINS = [
|
||||||
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include, url
|
from django.urls import include, path
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from django.views import defaults as default_views
|
from django.views import defaults as default_views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r"^$", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
||||||
url(
|
path(
|
||||||
r"^about/$",
|
"about/",
|
||||||
TemplateView.as_view(template_name="pages/about.html"),
|
TemplateView.as_view(template_name="pages/about.html"),
|
||||||
name="about",
|
name="about",
|
||||||
),
|
),
|
||||||
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
||||||
url(settings.ADMIN_URL, admin.site.urls),
|
path(settings.ADMIN_URL, admin.site.urls),
|
||||||
# User management
|
# User management
|
||||||
url(
|
path(
|
||||||
r"^users/",
|
"users/",
|
||||||
include("{{ cookiecutter.project_slug }}.users.urls", namespace="users"),
|
include("{{ cookiecutter.project_slug }}.users.urls", namespace="users"),
|
||||||
),
|
),
|
||||||
url(r"^accounts/", include("allauth.urls")),
|
path("accounts/", include("allauth.urls")),
|
||||||
# Your stuff: custom urls includes go here
|
# Your stuff: custom urls includes go here
|
||||||
] + static(
|
] + static(
|
||||||
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
|
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
|
||||||
|
@ -29,24 +29,24 @@ if settings.DEBUG:
|
||||||
# This allows the error pages to be debugged during development, just visit
|
# This allows the error pages to be debugged during development, just visit
|
||||||
# these url in browser to see how these error pages look like.
|
# these url in browser to see how these error pages look like.
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
url(
|
path(
|
||||||
r"^400/$",
|
"400/",
|
||||||
default_views.bad_request,
|
default_views.bad_request,
|
||||||
kwargs={"exception": Exception("Bad Request!")},
|
kwargs={"exception": Exception("Bad Request!")},
|
||||||
),
|
),
|
||||||
url(
|
path(
|
||||||
r"^403/$",
|
"403/",
|
||||||
default_views.permission_denied,
|
default_views.permission_denied,
|
||||||
kwargs={"exception": Exception("Permission Denied")},
|
kwargs={"exception": Exception("Permission Denied")},
|
||||||
),
|
),
|
||||||
url(
|
path(
|
||||||
r"^404/$",
|
"404/",
|
||||||
default_views.page_not_found,
|
default_views.page_not_found,
|
||||||
kwargs={"exception": Exception("Page not Found")},
|
kwargs={"exception": Exception("Page not Found")},
|
||||||
),
|
),
|
||||||
url(r"^500/$", default_views.server_error),
|
path("500/", default_views.server_error),
|
||||||
]
|
]
|
||||||
if "debug_toolbar" in settings.INSTALLED_APPS:
|
if "debug_toolbar" in settings.INSTALLED_APPS:
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
|
|
||||||
urlpatterns = [url(r"^__debug__/", include(debug_toolbar.urls))] + urlpatterns
|
urlpatterns = [path("__debug__/", include(debug_toolbar.urls))] + urlpatterns
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from django.conf.urls import url
|
from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
app_name = "users"
|
app_name = "users"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(regex=r"^$", view=views.UserListView.as_view(), name="list"),
|
path("", view=views.UserListView.as_view(), name="list"),
|
||||||
url(regex=r"^~redirect/$", view=views.UserRedirectView.as_view(), name="redirect"),
|
path("~redirect/", view=views.UserRedirectView.as_view(), name="redirect"),
|
||||||
url(regex=r"^~update/$", view=views.UserUpdateView.as_view(), name="update"),
|
path("~update/", view=views.UserUpdateView.as_view(), name="update"),
|
||||||
url(
|
path(
|
||||||
regex=r"^(?P<username>[\w.@+-]+)/$",
|
"<str:username>",
|
||||||
view=views.UserDetailView.as_view(),
|
view=views.UserDetailView.as_view(),
|
||||||
name="detail",
|
name="detail",
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user