Exemplo n.º 1
0
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 django.contrib.auth.decorators import login_required
from photos import views as views_photos
from users import views as views_users
from photos.views import HomeView, DetailView, CreateView, PhotoListView, UserPhotoView
from users.views import LoginView, LogoutView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    # Photos URLs
    url(r'^$', HomeView.as_view(), name='photos_home'),
    url(r'^photos/$',
        login_required(PhotoListView.as_view()),
        name='photos_list'),
    url(r'^my-photos/$', UserPhotoView.as_view(), name='user_photos'),
    url(r'^photos/(?P<pk>[0-9]+)$', DetailView.as_view(), name='photo_detail'),
    url(r'^photos/new$', CreateView.as_view(), name='create_photo'),

    # Users URLs
    url(r'^login$', LoginView.as_view(), name='users_login'),
    url(r'^logout$', LogoutView.as_view(), name='users_logout'),
]
Exemplo n.º 2
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from photos.views import HomeView, DetailView, CreateView, PhotoListView, UserPhotosView

urlpatterns = [
    #Photo urls
    url(r'^$', HomeView.as_view(), name='photos_home'),
    url(r'^my-photos/$', login_required(UserPhotosView.as_view()), name='user_photos'),
    url(r'^photos/$', PhotoListView.as_view(), name='photos_list'),
    url(r'^photos/(?P<pk>[0-9]+)$', DetailView.as_view(), name='photo_detail'),
    url(r'^photos/new$', CreateView.as_view(), name='create_photo'),
]
Exemplo n.º 3
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from photos.views import HomeView, DetailView, CreateView, PhotoListView, UserPhotosView


urlpatterns = [
    # Photos URLs
    url(r'^$', HomeView.as_view(), name='photos_home'),
    url(r'^my-photos/$', login_required(UserPhotosView.as_view()), name='user_photos'),
    url(r'^photos/$', PhotoListView.as_view(), name='photos_list'),
    url(r'^photos/(?P<pk>[0-9]+)$', DetailView.as_view(), name='photo_detail'),
    url(r'photos/new$', CreateView.as_view(), name='create_photo'),
]
Exemplo n.º 4
0
from photos.api import PhotoDetailAPI, PhotoListAPI
from photos.views import CreateView, DetailView, HomeView, PhotoListView, \
    UserPhotosView
from users.api import UserDetailAPI, UserListAPI
from users.views import LoginView, LogoutView

# r le dice que es una expresion regular  -^ iniciode cadena - $ fin de cadena
urlpatterns = [
    url(r'^admin/', admin.site.urls),

    #Photo URLs
    url(r'^$', HomeView.as_view(), name="photos_home"),
    url(r'^photos/(?P<pk>[0-9]+)/$', DetailView.as_view(),
        name="photo_detail"),
    url(r'^photos/new/$', CreateView.as_view(), name="photo_create"),
    url(r'^photos/$', PhotoListView.as_view(), name="photos_list"),
    url(r'^my-photos/$',
        login_required(UserPhotosView.as_view()),
        name="user_photos"),

    #Photos API URLs
    url(r'^api/1.0/photos/$', PhotoListAPI.as_view(), name='photo_list_api'),
    url(r'^api/1.0/photos/(?P<pk>[0-9]+)/$',
        PhotoDetailAPI.as_view(),
        name='photo_detail_api'),

    #Users URLs
    url(r'^login$', LoginView.as_view(), name='users_login'),
    url(r'^logout$', LogoutView.as_view(), name='users_logout'),

    #USers API URLs
Exemplo n.º 5
0
from django.conf.urls import url, include
from rest_framework.routers import DefaultRouter

from photos.api import PhotoViewSet
from photos.views import HomeView, PhotoDetailView, PhotoCreationView, PhotoListView

router = DefaultRouter()
router.register('api/1.0/photos', PhotoViewSet, base_name='api_photos')

urlpatterns = [
    url(r'^create$', PhotoCreationView.as_view(), name='photos_create'),
    url(r'^photos/$', PhotoListView.as_view(), name='photos_my_photos'),
    url(r'^photos/(?P<pk>[0-9]+)$', PhotoDetailView.as_view(), name='photos_detail'),
    url(r'^$', HomeView.as_view(), name='photos_home'),

    url(r'', include(router.urls))
]
Exemplo n.º 6
0
from django.urls import path
from photos.views import HomeView, PhotoListView, PhotoDetailView, CreateView,  UserPhotosView
from django.contrib.auth.decorators import login_required


urlpatterns = [

    path('', HomeView.as_view(), name='photos_home'),
    path('photos/<int:pk>', PhotoDetailView.as_view(), name='photos_detail'),
    path('photos/new/', CreateView.as_view(), name='create_photo'),
    path('photos/', PhotoListView.as_view(), name='photos_list'),
    path('my-photos/', login_required(UserPhotosView.as_view()), name='user_photos'),


]
Exemplo n.º 7
0
from photos.views import HomeView, DetailView, CreateView, PhotoListView, UserPhotosView
from users.views import LoginView, LogoutView
from users.api import UserListAPI, UserDetailApi
from django.contrib.auth.decorators import login_required
from photos.api import PhotoListApi, PhotoDetailApi

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),

    #para el request vacio (r'^$') busca en el paquete photos.views.home
    url(r'^$', HomeView.as_view(), name='photos_home'),

    #(?P<pk>) significa capturar el valor que llega para luego usarlo con el nombre pk
    url(r'^photos/(?P<pk>[0-9]+)$', DetailView.as_view(), name='photo_detail'),
    url(r'^photos/new$', CreateView.as_view(), name='create_photo'),
    url(r'^photos/$', login_required(PhotoListView.as_view()), name='photos_list'),
    url(r'^photos/my-photos$', UserPhotosView.as_view(), name = 'user_photos'),

    #Users URLS
    url(r'^login$', LoginView.as_view(), name='users_login'),
    url(r'^logout$', LogoutView.as_view(), name='users_logout'),

    #Users API URL's
    url(r'^api/1.0/users/$', UserListAPI.as_view(), name='users_list_api'),
    url(r'^api/1.0/users/(?P<pk>[0-9]+)$', UserDetailApi.as_view(), name='user_detail_api'),

    #Photos API
     url(r'^api/1.0/photos/$', PhotoListApi.as_view(), name='photo_list_api'),
     url(r'^api/1.0/photos/(?P<pk>[0-9]+)$', PhotoDetailApi.as_view(), name='photo_detail_api'),

]
Exemplo n.º 8
0
from django.conf.urls import url

from photos.views import HomeView, PhotoDetailView, PhotoCreationView, PhotoListView

urlpatterns = [
    url(r'^create$', PhotoCreationView.as_view(), name="photos_create"),
    url(r'^photos/$', PhotoListView.as_view(), name="photos_my_photos"),
    url(r'^photos/(?P<pk>[0-9]+)$', PhotoDetailView.as_view(), name="photos_detail"),
    url(r'^$', HomeView.as_view(), name="photos_home")
]
Exemplo n.º 9
0
# encoding: utf-8
'''
	the url routing tables of photos' app
'''
from django.conf.urls import patterns, url
from photos import views
from photos.views import PhotoListView, PhotoDetailView


urlpatterns = patterns('',
	url(r'^rate/(?P<photo_id>\d+)/$', views.rate, name='rate'),
	url(r'^(?P<photo_id>\d+)/$', views.details, name='details'),
	# url(r'^(?P<pk>\d+)/$', PhotoDetailView.as_view(), name='details'),
	# url(r'^$', views.index, name='index'),
	url(r'^$', PhotoListView.as_view(), name='index'),
)