예제 #1
0
from django.conf import settings
from django.contrib import admin
from django.urls import path, include
from django.views.generic import TemplateView
from django.shortcuts import redirect
from contents.views import HomeView, RelationView
from django.conf.urls.static import static

class NonUserTemplateView(TemplateView):
    def dispatch(self, request, *args, **kwargs):
        if not request.user.is_anonymous:
            return redirect('contents_home')
        return super(NonUserTemplateView, self).dispatch(request, *args, **kwargs)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', HomeView.as_view(), name='contents_home'),
    path('login/', NonUserTemplateView.as_view(template_name='login.html'), name='login'),
    path('register/', NonUserTemplateView.as_view(template_name='register.html'), name='register'),
    path('relation/', RelationView.as_view(), name='contents_relation'),
    path('api/', include('api.urls')),
]

if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [path('__debug__/', include(debug_toolbar.urls))]
    # urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) AWS저장소를 이용하기 때문에 주석처리

예제 #2
0
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 include, path
from django.views.generic import TemplateView

from contents.views import HomeView

urlpatterns = [
    path('admin/', admin.site.urls),
    # 05. API - 03. 예외처리와 아이디, 이메일 등 검증하는 로직 만들기
    path('apis/', include('apis.urls')),
    # 06. API - 05. 로그인 테스트 해볼 수 있는 페이지 만들기
    path('login_test', HomeView.as_view(), name='contents_home'),
    # 08. API - 07. 로그인 페이지 분리
    path('login/',
         TemplateView.as_view(template_name='login.html'),
         name='login'),
]
예제 #3
0
from django.conf import settings
from django.conf.urls.static import static

from apis.views import UserLogoutView
from contents.views import HomeView, RelationView


class NonUserTemplateView(TemplateView):
    def dispatch(self, request, *args, **kwargs):
        if not request.user.is_anonymous:
            return redirect('home')
        return super(NonUserTemplateView,
                     self).dispatch(request, *args, **kwargs)


urlpatterns = [
    path('admin/', admin.site.urls),
    path('apis/', include('apis.urls')),
    path('', HomeView.as_view(), name='home'),
    path('register/',
         NonUserTemplateView.as_view(template_name='register.html'),
         name='register'),
    path('login/',
         NonUserTemplateView.as_view(template_name='login.html'),
         name="login"),
    path('logout/', UserLogoutView.as_view(), name="logout"),
    path('relation/', RelationView.as_view(), name="relation"),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
예제 #4
0
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.views.generic import TemplateView

from users.views import UserJoinView, UserLoginView, UserLogoutView
from contents.views import HomeView, GramAddView

urlpatterns = [
    path("s/a/console/", admin.site.urls),
    path("", HomeView.as_view()),
    path("login/", TemplateView.as_view(template_name="login.html")),
    path("join/", TemplateView.as_view(template_name="join.html")),
    path("api/users/", UserJoinView.as_view()),
    path("api/login/", UserLoginView.as_view()),
    path("api/logout/", UserLogoutView.as_view()),
    path("api/contents/", GramAddView.as_view()),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
예제 #5
0
from django.conf.urls import patterns, url
from django.views.generic.base import TemplateView

from contents.views import (
    ContactView, TextTemplateView, HomeView
)


urlpatterns = patterns('',

    url(r'^$', HomeView.as_view(), name="index"),

    url(r'^contact/$', ContactView.as_view(
        template_name="contents/contact.html"
    ), name="contact"),

    url(r'^contact/success/$', TemplateView.as_view(
        template_name="contents/contact_success.html"
    ), name="contact_success"),

    # static files
    url(r'^humans.txt$', TextTemplateView.as_view(
        template_name="humans.txt"
    ), name="humans"),

    url(r'^robots.txt$', TextTemplateView.as_view(
        template_name="robots.txt",
    ), name="robots"),

)