mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-26 03:24:01 +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 Osipenko `@romanosipenko`_
|
||||
Russell Davies
|
||||
Sascha `@saschalalala` @saschalalala
|
||||
Sam Collins `@MightySCollins`_
|
||||
Shupeyko Nikita `@webyneter`_
|
||||
Sławek Ehlert `@slafs`_
|
||||
|
|
|
@ -18,7 +18,7 @@ Run these commands to deploy the project to Heroku:
|
|||
|
||||
heroku config:set WEB_CONCURRENCY=4
|
||||
# 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_SETTINGS_MODULE=config.settings.production
|
||||
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
|
||||
======================================= =========================== ============================================== ======================================================================
|
||||
DJANGO_ADMIN_URL n/a r'^admin/' raises error
|
||||
DJANGO_ADMIN_URL n/a 'admin/' raises error
|
||||
DJANGO_CACHES CACHES (default) locmem redis
|
||||
DJANGO_DATABASES DATABASES (default) See code See code
|
||||
DJANGO_DEBUG DEBUG True False
|
||||
|
|
|
@ -154,7 +154,7 @@ def set_django_admin_url(file_path):
|
|||
django_admin_url = set_flag(
|
||||
file_path,
|
||||
"!!!SET DJANGO_ADMIN_URL!!!",
|
||||
formatted="^{}/",
|
||||
formatted="{}/",
|
||||
length=32,
|
||||
using_digits=True,
|
||||
using_ascii_letters=True,
|
||||
|
|
|
@ -216,8 +216,8 @@ EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.s
|
|||
|
||||
# ADMIN
|
||||
# ------------------------------------------------------------------------------
|
||||
# Django Admin URL regex.
|
||||
ADMIN_URL = r'^admin/'
|
||||
# Django Admin URL.
|
||||
ADMIN_URL = 'admin/'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
||||
ADMINS = [
|
||||
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
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.contrib import admin
|
||||
from django.views.generic import TemplateView
|
||||
from django.views import defaults as default_views
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^$", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
||||
url(
|
||||
r"^about/$",
|
||||
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
||||
path(
|
||||
"about/",
|
||||
TemplateView.as_view(template_name="pages/about.html"),
|
||||
name="about",
|
||||
),
|
||||
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
||||
url(settings.ADMIN_URL, admin.site.urls),
|
||||
path(settings.ADMIN_URL, admin.site.urls),
|
||||
# User management
|
||||
url(
|
||||
r"^users/",
|
||||
path(
|
||||
"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
|
||||
] + static(
|
||||
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
|
||||
# these url in browser to see how these error pages look like.
|
||||
urlpatterns += [
|
||||
url(
|
||||
r"^400/$",
|
||||
path(
|
||||
"400/",
|
||||
default_views.bad_request,
|
||||
kwargs={"exception": Exception("Bad Request!")},
|
||||
),
|
||||
url(
|
||||
r"^403/$",
|
||||
path(
|
||||
"403/",
|
||||
default_views.permission_denied,
|
||||
kwargs={"exception": Exception("Permission Denied")},
|
||||
),
|
||||
url(
|
||||
r"^404/$",
|
||||
path(
|
||||
"404/",
|
||||
default_views.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:
|
||||
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
|
||||
|
||||
app_name = "users"
|
||||
urlpatterns = [
|
||||
url(regex=r"^$", view=views.UserListView.as_view(), name="list"),
|
||||
url(regex=r"^~redirect/$", view=views.UserRedirectView.as_view(), name="redirect"),
|
||||
url(regex=r"^~update/$", view=views.UserUpdateView.as_view(), name="update"),
|
||||
url(
|
||||
regex=r"^(?P<username>[\w.@+-]+)/$",
|
||||
path("", view=views.UserListView.as_view(), name="list"),
|
||||
path("~redirect/", view=views.UserRedirectView.as_view(), name="redirect"),
|
||||
path("~update/", view=views.UserUpdateView.as_view(), name="update"),
|
||||
path(
|
||||
"<str:username>",
|
||||
view=views.UserDetailView.as_view(),
|
||||
name="detail",
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue
Block a user