"""url_shortner URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.1/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 HomeView, UrlRedirectView urlpatterns = [ path('admin/', admin.site.urls), path('', HomeView.as_view()), path('<shortcode>/', UrlRedirectView.as_view(), name='scode'), ]
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), ]
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 # Importa las views (nuevo método Django 1.10) from shortener.views import AxioRedirectView, HomeView # PROHIBIDO HACER: # from shortener import views ---> se importa el archivo entero de views! # from otra_app.views import views # EL ORDEN DE LAS URLs IMPORTA, SE DAN PRIORIDAD A LAS PRIMERAS urlpatterns = [ url(r'^manage/', admin.site.urls), url(r"^$", HomeView.as_view()), url(r"^(?P<shortcode>[\w-]+){6,15}/$", AxioRedirectView.as_view()), # PROHIBIDO HACER: # url(r"^prueba/$", "shortener.views.axio_redirect_view"), # url(r"^prueba/$", views.axio_redirect_view), ]
"""milan 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'^(?P<shortcode>[\w-]+)/$', UrlRedirectView.as_view(), name='view2'), url(r'^', HomeView.as_view(), 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 import settings from django.conf.urls import url from django.contrib import admin from django.views.generic import RedirectView from django.conf.urls.static import static from shortener.views import HomeView, kerr_redirect_view, KerrRedirectView # https://github.com/codingforentrepreneurs/Guides/blob/master/all/common_url_regex.md urlpatterns = [ url(r'^djadmin/', admin.site.urls), url(r'^$', HomeView.as_view(), name="Homepage"), url(r'^view-1/$', kerr_redirect_view), url(r'^view-2/$', KerrRedirectView.as_view()), # url(r'(?P<shortcode>[\w-]+){6,15}/$', kerr_redirect_view), # wrong # url(r'^(?P<shortcode>[\w-]+)/$', URLRedirectView.as_view(), name='scode'), url(r'a/(?P<shortcode>[\w-]{4,15})/$', KerrRedirectView.as_view(), name='shorturl'), url(r'b/(?P<shortcode>[\w-]+)/$', kerr_redirect_view), url(r'^favicon\.ico$', RedirectView.as_view(url='/static/images/favicon.ico')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
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'), ]
"""url_shortener URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.0/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, include, re_path from shortener.views import ShortenerView, HomeView, about urlpatterns = [ path("admin/", admin.site.urls, name="admin"), path("", HomeView.as_view(), name="home"), path("about/", about, name="about"), path("<str:shortcode>/", ShortenerView.as_view(), name="shortener-view"), ]
"""url_shortener URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/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, ShortRedirectView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', HomeView.as_view( ), name='shortener_home'), url(r'^(?P<shortcode>[\w]+)/$', ShortRedirectView.as_view(), name='scode') ]
"""Short URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/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 Kirr, HomeView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^shortener/$', HomeView.as_view()), url(r'^(?P<shortcode>[\w-]+)/', Kirr.as_view(), name='shortcode') ]
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(), name='index'), url(r'^(?P<shortcode>[\w-]+)/$', URLRedirectView.as_view(), name='scode'), ]
from django.urls import path, re_path from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from shortener.views import HomeView, URLRedirectView, AcercaDeView urlpatterns = [ path('admin/', admin.site.urls), path('', HomeView.as_view(), name='home'), path('acerca/', AcercaDeView.as_view(), name='acerca'), re_path(r'^(?P<shortcode>[\w-]+)/$', URLRedirectView.as_view(), name='scode' ), ] if settings.DEBUG == False: # static files (images, css, javascript, etc.) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.conf.urls import url from django.contrib import admin from shortener.views import RedirectView, HomeView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', HomeView.as_view()), url(r'^(?P<shortcode>[\w-]{8,16})/$', RedirectView.as_view()), ]
"""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"), ]
"""kirr 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 KirrCBView, HomeView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', HomeView.as_view()), #url(r'^a/(?P<shortcode>[\w-]+){6,15}/$', kirr_redirect_view), url(r'^b/(?P<shortcode>[\w-]+){6,15}/$', HomeView.as_view(), name='shortcode'), ]