urlpatterns = [
    # (?P<pk>[0-9]+) => valor en parámetro pk (?P<pk>), que será 1 o más números del 0 al 9

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

    # urls nombradas
    url(r'^blogs/$', BlogsView.as_view(), name='blog_home'),    # listado de blogs, con vista basada en clase BlogsView
    url(r'^$', HomeView.as_view(), name='post_home'),           # listado de posts publicados, con vista basada en clase HomeView
    url(r'^blogs/(?P<username>[a-z]+)/$', UserPostsView.as_view(), name='blog_posts'),     # listado posts blog usuario, basada en la clase UserPostView
    url(r'^blogs/(?P<username>[a-zA-Z]+)/(?P<post_id>[0-9]+)$', DetailView.as_view(), name='post_detail'),   # detalle post, basado en clase DetailView


    url(r'^signup/$', SignupView.as_view(), name='user_signup'), # signup o creación de cuenta de usuario, con vista basada en clase SignupView
    url(r'^login$', LoginView.as_view(), name='user_login'),    # login, con vista basada en clase LoginView
    url(r'^logout$', LogoutView.as_view(), name='user_logout'), # logout, con vista basada en clase LogoutView

    url(r'^new-post/$', CreateView.as_view(), name='post_create'),   # creación nuevo post, con vista basada en clase CreateView


    # Users' API URLs
    url(r'^api/1.0/users/$', UserListAPI.as_view(), name='user_list_api'),      # url con listado de users para la API, basado en clases
    url(r'^api/1.0/users/(?P<pk>[0-9]+)$', UserDetailAPI.as_view(), name='user_detail_api'),     #url detalle usuario para la api

    # Posts' API URLs
    url(r'^api/1.0/blogs/(?P<username>[a-z]+)/$', PostListAPI.as_view(), name='post_list_api'),     # API listado de posts de blog
    url(r'^api/1.0/posts/(?P<pk>[0-9]+)$', PostDetailAPI.as_view(), name='post_detail_api'),     # API detalle de post: CRUD.

    # Blogs' API URLs
    url(r'^api/1.0/blogs/$', BlogListAPI.as_view(), name='blog_list_api')  # API listado blogs
]
Ejemplo n.º 2
0
    url(r'^new-post$', CreatePostView.as_view(), name='create_post'),
    url(r'^update-post/(?P<pk>[-\w]+)/(?P<idPost>[0-9]+)/$', UpdatePostView.as_view(), name='update_post'),

    # Posts API URLs
    # Listado de posts para la home/Creacion de un post nuevo
    url(r'api/1.0/posts/$', PostListAPI.as_view(), name='post_list_api'),

    #Blogs URLs
    url(r'^blogs/$', BlogsView.as_view(), name='blogs'),
    url(r'^blogs/(?P<pk>[-\w]+)/$', DetailBlogView.as_view(), name='blog_detail'),

    # Blogs API URLs
    # Listado de blogs
    url(r'api/1.0/blogs/$', BlogsListAPI.as_view(), name='blog_list_api'),
    # Detalle de un blog: listado de posts del blog
    url(r'api/1.0/blogs/(?P<pk>[-\w]+)/$', BlogDetailAPI.as_view(), name='blog_detail_api'),
    # Detalle/Actualizacion/Borrado de un post
    url(r'api/1.0/blogs/(?P<pk>[-\w]+)/(?P<idPost>[0-9]+)/$', PostDetailAPI.as_view(), name='blog_detail_api'),

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

    # Users API URLs
    #Listar usuarios/Crear un nuevo usuario
    url(r'api/1.0/users/$', UserListAPI.as_view(), name='user_list_api'),
    # Detalle/Actualizacion/Borrado de un usuario
    url(r'api/1.0/users/(?P<pk>[0-9]+)$', UserDetailAPI.as_view(), name='user_detail_api')
]
Ejemplo n.º 3
0
from movies.api import MoviesListAPI, MovieDetailAPI, CategoryViewSet
from movies.views import movie_detail, home, CreateMovieView, MyMoviesView
from users.api import HelloWorld, UsersListAPI, UserDetailAPI
from users.views import logout, LoginView

router = SimpleRouter()
router.register('categories', CategoryViewSet)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('login/', LoginView.as_view(), name="login_page"),
    path('logout/', logout, name="logout_page"),
    path('pelis/crear', CreateMovieView.as_view(), name="create_movie_page"),
    path('movies/<int:pk>', movie_detail, name="movie_detail_page"),
    path('pelis/', MyMoviesView.as_view(), name="my_movies_page"),
    path('', home, name="home_page"),

    # API REST
    path('api/1.0/hello/', HelloWorld.as_view(), name="api_hello_world"),
    path('api/1.0/users/<int:pk>',
         UserDetailAPI.as_view(),
         name="api_user_detail"),
    path('api/1.0/users/', UsersListAPI.as_view(), name="api_users_list"),
    path('api/1.0/movies/<int:pk>',
         MovieDetailAPI.as_view(),
         name="api_movies_detail"),
    path('api/1.0/movies/', MoviesListAPI.as_view(), name="api_movies_list"),
    path('api/1.0/', include(router.urls))
]
Ejemplo n.º 4
0
from django.conf import settings

from django.urls import path
from posts import views
from posts import views as post_views
from users import views as users_views
from users.api import UsersAPI, UserDetailAPI
from posts.api import PostsAPI, PostsDetailAPI

urlpatterns = [

    path('admin/', admin.site.urls),

    path('', post_views.PostsFeedView.as_view(), name='feed'),
    path('posts/new/', views.CreatePostView.as_view(), name='create_post'),
    path('posts/<str:username>/<int:pk>/', views.PostDetailView.as_view(), name='post_detail'),

    path('blogs/<str:username>', users_views.UserDetailView.as_view(), name='user_blog'),

    path('login/', users_views.LoginView.as_view(), name='login'),
    path('logout', users_views.LogoutView.as_view(), name='logout'),
    path('signup', users_views.SignupView.as_view(), name='signup'),

    # API
    path('api/users/', UsersAPI.as_view(), name='users_api'),
    path('api/users/<int:pk>', UserDetailAPI.as_view(), name='user_detail'),
    path('api/posts/', PostsAPI.as_view(), name='posts_api'),
    path('api/posts/<int:pk>', PostsDetailAPI.as_view(), name='posts_detail'),

] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Ejemplo n.º 5
0
from django.contrib.auth import views as auth_views

from posts.api import PostsListAPI, PostCreateAPI, PostDetailAPI
from posts.views import home, my_blog, user_posts, CreatePostView, post_detail
from users.api import UsersListAPI, UserDetailAPI, BlogsListAPI
from users.views import blogs, signup


urlpatterns = [
    path('admin/', admin.site.urls),

    path('', home, name='home'),

    path('login', auth_views.login, {'template_name': 'login.html'}, name="login"),
    path('logout', auth_views.logout, {'next_page': '/'}, name="logout"),
    path('signup', signup, name="signup"),

    path('my_blog', my_blog, name="my_blog"),
    path('blogs/<username>', user_posts, name="user_posts"),
    path('blogs', blogs, name="blogs"),
    path('new-post', CreatePostView.as_view(), name="new_post"),
    path('blogs/<username>/<int:pk>', post_detail, name="post_detail"),

    path('api/1.0/users', UsersListAPI.as_view(), name="api_users"),
    path('api/1.0/users/<int:pk>', UserDetailAPI.as_view(), name="api_user"),
    path('api/1.0/blogs', BlogsListAPI.as_view(), name="api_blogs"),
    path('api/1.0/blogs/<username>', PostsListAPI.as_view(), name="api_blog"),
    path('api/1.0/posts/create', PostCreateAPI.as_view(), name="api_post_create"),
    path('api/1.0/posts/<int:pk>', PostDetailAPI.as_view(), name="api_post"),
]
from users.views import login, logout, SignUpFormView

urlpatterns = [
    path('admin/', admin.site.urls),

    # Users
    path('login', login, name='login'),
    path('logout', logout, name='logout'),
    path('signup', SignUpFormView.as_view(), name='signup'),

    # posts
    path('blogs/<str:name>/<int:pk>/', post_detail, name='post_detail'),
    path('blogs/<str:name>/', UserPostsView.as_view(), name='blog_user'),
    path('all_posts', PostsListView.as_view(), name='post_list'),
    path('post/new/', new_post, name='new_post'),

    # blogs
    path('blogs', BlogsListView.as_view(), name='blogs'),

    # home
    path('', LatestPostsView.as_view(), name='home'),

    # API
    path('api/posts/<int:pk>', PostDetailAPI.as_view(),
         name='post_detail_api'),
    path('api/posts/<str:name>', PostsAPI.as_view(), name='posts_api'),
    path('api/users/<int:pk>', UserDetailAPI.as_view(),
         name='user_detail_api'),
    path('api/users', UserAPI.as_view(), name='posts_api')
]
Ejemplo n.º 7
0
from users.views import login, logout, SignUpView, SignupSuccessfulView
from django.conf.urls import url
from users.api import UserListAPI, UserDetailAPI

urlpatterns = [
    #web urls
    url(r'^login$', login),
    url(r'^logout$', logout),
    url(r'^signup$', SignUpView.as_view(), name='signup'),
    url(r'^success$', SignupSuccessfulView.as_view(), name='signup_success'),

    #api urls
    url(r'^api/1.0/users/$', UserListAPI.as_view(), name='api_user_list'),
    url(r'^api/1.0/users/(?P<pk>[0-9]+)$', UserDetailAPI.as_view(), name='api_user_detail')
]
Ejemplo n.º 8
0
from users.views import LoginView, logout, SignupView

from users.api import HelloWorld, UsersListAPI, UserDetailAPI
from blogs.api import BlogsListAPI, PostsListAPI, PostDetailAPI
from rest_framework.authtoken import views

urlpatterns = [
    path('admin/', admin.site.urls),

    path('login', LoginView.as_view(), name="login_page"),
    path('logout', logout, name="logout_page"),
    path('signup', SignupView.as_view(), name="signup_page"),

    path('blogs/<slug:username>', UserPostsView.as_view(), name="user_posts_page"),
    path('blogs/<slug:username>/<int:pk>', post_detail, name="post_detail_page"),
    path('blogs/', blogs, name='blogs_page'),
    path('new-post/', CreatePostView.as_view(), name="create_post_page"),
    path('', home, name="home_page"),

    # API REST
    path('api/1.0/hello', HelloWorld.as_view(), name="api_hello_world"),
    path('api/1.0/users/<slug:pk>', UserDetailAPI.as_view(), name="api_users_detail"),
    path('api/1.0/users', UsersListAPI.as_view(), name="api_users_list"),
    path('api/1.0/blogs', BlogsListAPI.as_view(), name="api_blogs_list"),
    path('api/1.0/posts/<int:pk>', PostDetailAPI.as_view(), name="api_posts_detail"),
    path('api/1.0/posts', PostsListAPI.as_view(), name="api_posts_list"),

    path('api/1.0/users/get-token', views.obtain_auth_token, name="api_get_token"),

]