예제 #1
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', 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'))
"""
from django.conf.urls import url
from django.contrib import admin

# from shortener.views import kirr_redirect_FBV, KirrRedirectCBView, test_view  # for Django 1.10 this is required

from shortener.views import HomeView, URLRedirectView

# DO NOT USE LIKE THIS BELOW with like as older DJANGO versions
# from shortener import views
# from another_app.views import views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', HomeView.as_view()),

    # url(r'^about123/$', test_view),
    # url(r'^(?P<shortcode>[\w-]+){6,15}$', kirr_redirect_FBV),
    url(r'^(?P<shortcode>[\w-]+)/$', URLRedirectView.as_view(), name='scode'),
    # refer https://github.com/codingforentrepreneurs/Guides/blob/master/all/common_url_regex.md

    # DO NOT USE LIKE THIS BELOW with like as older DJANGO versions
    # url(r'^view-2/$', 'shortener.views.KirrRedirectCBView'),
    # url(r'^view-2/$', views.KirrRedirectCBView),
]
예제 #2
0
from django.contrib import admin
from django.urls import path, re_path

from shortener.views import HomeView, URLRedirectView
urlpatterns = [
    re_path(r'^admin/', admin.site.urls),
    re_path(r'^$', HomeView.as_view()),
    re_path(r'^(?P<shortcode>[\w-]+)/$',
            URLRedirectView.as_view(),
            name='scode'),
]
예제 #3
0
from django.conf.urls import url
from django.contrib import admin
from django.urls import path

from django.urls import include, path

from shortener.views import HomeView, URLRedirectView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view()),
    path('<shortcode>/', URLRedirectView.as_view(), name='scode'),
]
예제 #4
0
from django.conf.urls import url
from django.contrib import admin

from shortener.views import HomeView, URLRedirectView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', HomeView.as_view()),
    url(r'(?P<shortcode>[\w-]+)$', URLRedirectView.as_view(), name="scode"),
]
예제 #5
0
"""djangoURLShortner URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    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:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from shortener.views import shortened_redirect_view, URLRedirectView, HomeView



urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view()),
    # path('<shortcode>', shortened_redirect_view),  # should be last in the list
    path('<shortcode>', URLRedirectView.as_view(), name='scode')  # in the list


]
예제 #6
0
"""testing URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.10/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')
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')
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'))
"""
from django.conf.urls import url
from django.contrib import admin
from shortener.views import HomeView, URLRedirectView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^home/$', HomeView.as_view()),
    url(r'^(?P<shortcode>[\w]+)/', URLRedirectView.as_view(), name="scode"),
]