from django.urls import path from books.views import BookListView, BookDetailView urlpatterns = [ path('', BookListView.as_view(), name='book_list'), path('<uuid:pk>', BookDetailView.as_view(), name='book_detail'), ]
def test_access_authenticated(self): req = RequestFactory().get(reverse('books:list')) req.user = mixer.blend(User) resp = BookListView.as_view()(req) assert resp.status_code == 200, 'Should display booklist'
from django.urls import path from django.views.generic import TemplateView from books.views import BookListView, BookDetailView, AuthorListView, AuthorDetailView, SearchResultsView, \ ReviewDeleteView, ReviewEditView urlpatterns = [ path('about/', TemplateView.as_view(template_name='about.html'), name='about'), path('search/', SearchResultsView.as_view(), name='search_results'), path('books/', BookListView.as_view(), name='books'), path('books/<uuid:pk>', BookDetailView.as_view(), name='book_detail'), path('authors/', AuthorListView.as_view(), name='authors'), path('authors/<int:pk>', AuthorDetailView.as_view(), name='author_detail'), path('review/<int:pk>', ReviewDeleteView.as_view(), name='review_delete'), path('review/edit/<int:pk>', ReviewEditView.as_view(), name='review_edit'), ]
"""main 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, register_converter from books.views import BookListView from books.converters import PubDateConverter register_converter(PubDateConverter, 'date_convert') urlpatterns = [ path('admin/', admin.site.urls), path('books/', BookListView.as_view(), name='books'), path('books/<date_convert:pub_date>', BookListView.as_view(), name='books'), ]
from django.urls import path from books.views import BookListView urlpatterns = [path('', BookListView.as_view(), name='home')]
from django.conf.urls import url from books.views import BookListView urlpatterns = [ url(r'books$', BookListView.as_view(), name="book-list"), ]
from books.views import BookListView from gesfi.views import * urlpatterns = [ url(r'^admin/', include(admin.site.urls)), #### Blog ####### # url(r'^$', 'blog.views.index'), url(r'^genres/$', 'blog.views.show_genres'), url(r'^blog/', 'blog.views.post_list'), url(r'^meta/', 'blog.views.display_meta'), url(r'^time/$', 'blog.views.current_datetime'), url(r'^time/plus/(\d{1,2})/$', 'blog.views.hours_ahead'), url(r'^products/$', CategoryListView.as_view()), url(r'^some_view/$','blog.views.some_view'), #### Books ####### # url(r'^search-form/$', 'books.views.search_form'), url(r'^search/$', 'books.views.search'), url(r'^contact/$', 'books.views.contact'), url(r'^books/$', BookListView.as_view()), #### GesFi ####### url(r'^$', 'gesfi.views.main_page'), url(r'^user/(\w+)/$', user_page), url(r'^transactions/(\w+)/$', transactions_page), url(r'^login/$', 'django.contrib.auth.views.login'), url(r'^logout/$', logout_page), ]
from django.conf.urls import url from books.views import BookListView, BookCreate, BookUpdate, BookDelete urlpatterns = [ url(r'^$', BookListView.as_view(), name='book-list'), url(r'^add/$', BookCreate.as_view(), name='book-add'), url(r'^edit/(?P<pk>[0-9]+)/$', BookUpdate.as_view(), name='book-edit'), url(r'^delete/(?P<pk>[0-9]+)/$', BookDelete.as_view(), name='book-delete'), ]
"""main 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 books.views import BookListView urlpatterns = [ path('admin/', admin.site.urls), path('books/', BookListView.as_view(), name='books'), path('books/<pub_date>/', BookListView.as_view(), name='books_by_date'), ]
"""main 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 books.views import BookListView urlpatterns = [ path('admin/', admin.site.urls), path('books/', BookListView.as_view()), path('books/<str:pub_date>', BookListView.as_view()), ]
path('update-series/<int:series_id>', book_view.book_update_series, name='update-series'), path('delete-series/<int:series_id>', book_view.book_delete_series, name='delete-series'), path('create-genre/', book_view.book_create_genre, name='create-genre'), path('update-genre/<int:genre_id>', book_view.book_update_genre, name='update-genre'), path('delete-genre/<int:genre_id>', book_view.book_delete_genre, name='delete-genre'), path('create-publisher/', book_view.book_create_publisher, name='create-publisher'), path('update-publisher/<int:publisher_id>', book_view.book_update_publisher, name='update-publisher'), path('delete-publisher/<int:publisher_id>', book_view.book_delete_publisher, name='delete-publisher'), path('', BookListView.as_view(), name='books-view'), path('authors-view/', AuthorListView.as_view(), name='authors-view'), path('book-view/<int:pk>/', BookDetailView.as_view(), name='book-view'), path('book-create-view/', BookCreateView.as_view(), name='book_create'), path('book-update/<int:pk>/', BookUpdateView.as_view(), name='book_update'), path('book-delete/<int:pk>/', BookDeleteView.as_view(), name='book_delete'), ]
def dispatch(self, request, *args, **kwargs): if request.user.is_authenticated(): return BookListView.as_view()(request) return super(HomeView, self).dispatch(request, *args, **kwargs)
"""main 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 books.views import BookListView, BookDateView urlpatterns = [ path('admin/', admin.site.urls), path('books/', BookListView.as_view(), name='catalogue'), path('books/<pub_date>/', BookDateView.as_view(), name='by_date') ]
"""bookinventory URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.9/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 books.views import BookCreateView, BookListView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^books/$', BookListView.as_view(), name="book-list"), url(r'^books/create/$', BookCreateView.as_view(), name="new-book"), ]
"""config URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.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, include from books.views import BookListView urlpatterns = [path("", BookListView.as_view(), name="home")]
from django.urls import path from books.views import BookListView urlpatterns = [ path('', BookListView.as_view(), name='home'), ]
from django.conf.urls import url from books.views import IndexView, BookView, ChapterView, BookListView urlpatterns = [ url(r'index/$', IndexView.as_view(), name='index'), url(r'^booklist/(?P<pk>\d+)/$', BookListView.as_view(), name='booklist'), url(r'^book/(?P<pk>\d+)/$', BookView.as_view(), name='book'), url(r'^chapter/(?P<pk>\d+)/$', ChapterView.as_view(), name='chapter'), ]
"""main 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 books.views import BookListView, BookListDateView urlpatterns = [ path('admin/', admin.site.urls), path('books/', BookListView.as_view()), path('books/<str:date>', BookListDateView.as_view()) ]
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 import views as auth_views from books.views import ( AddBookView, BookView, BookListView, CatalogView, DeleteBookView, LogoutView, UpdateBookView, ReaderView ) urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^catalog', CatalogView.as_view(), name='homepage'), url(r'^add_book', AddBookView.as_view(), name='add-book'), url(r'^book/(?P<book_id>(\d)+)', BookView.as_view(), name='book'), url(r'^book_list/$', BookListView.as_view(), name='books'), url(r'^update_book/(?P<pk>\d+)', UpdateBookView.as_view(), name='upd-book'), url(r'^delete_book/(?P<pk>\d+)', DeleteBookView.as_view(), name='delete-view'), url(r'^login/$', auth_views.login, {'template_name': 'books/login.html'}, name='login'), url(r'^logout', LogoutView.as_view(), name='logout'), url(r'^reader$', ReaderView.as_view(), name='reader') ]
from django.urls import path from .views import ClubListView, ClubDetailView from books.views import BookListView urlpatterns = [ path('', ClubListView.as_view()), path('<int:pk>/', ClubDetailView.as_view()), path('<int:pk>/books', BookListView.as_view()), path('<int:pk>/books/create/', ClubDetailView.as_view()), # path('<int:pk>/members/', ClubDetailView.as_view()), ]
from django.urls import path from books.views import ( BookListView, BookDetailView, BookCreateView, BookUpdateView, ) app_name = "books" urlpatterns = [ path("", BookListView.as_view(), name="books"), path("create", BookCreateView.as_view(), name="book_create"), path("update/<int:pk>", BookUpdateView.as_view(), name="book_update"), path("<int:pk>", BookDetailView.as_view(), name="book_detail"), ]
"""main 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, register_converter from books.views import BookListView from books.converters import PubDateConverter register_converter(PubDateConverter, 'year_book_pub') urlpatterns = [ path('books/', BookListView.as_view(), name='BookListView'), path('books/<year_book_pub:date>', BookListView.as_view(), name='BookListView'), path('admin/', admin.site.urls), ]
from django.urls import path, include from books.views import BookListView, BookDetailView, ChapterListView, ArticleDetailView, BookNotesListView, \ BookNotesDetailView, BookNotesArchiveView, BookNotesDeleteView, BookNotesEditView app_name = 'books' urlpatterns = [ path('book/list/', BookListView.as_view(), name='book-list'), path('book/<int:pk>/detail/', BookDetailView.as_view(), name='book-detail'), path('<int:pk>/chapter/list/', ChapterListView.as_view(), name='book-read'), path('article/<int:pk>/detail/', ArticleDetailView.as_view(), name='article-detail'), path('booknotes/list/', BookNotesListView.as_view(), name='booknotes-list'), path('booknotes/<int:pk>/detail/', BookNotesDetailView.as_view(), name='booknotes-detail'), path('booknotes/delete/', BookNotesDeleteView.as_view(), name='booknotes-delete'), path('booknotes/<int:pk>/edit/', BookNotesEditView.as_view(), name='booknotes-edit'), path('archive/<int:year>/<int:month>/<int:day>/', BookNotesArchiveView.as_view(), name='booknotes_archive'), ]
from django.conf.urls import include, url from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from books.views import BookListView urlpatterns = [ url(r'^$', BookListView.as_view(), name='index'), url(r'^admin/', admin.site.urls), url(r'^books/', include('books.urls', namespace='books')), url(r'^authors/', include('authors.urls', namespace='authors')), url(r'^users/', include('users.urls', namespace='users')), url(r'^card/', include('card.urls', namespace='card')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path from books.views import BookListView, BookDetailView, BookDeleteView urlpatterns = [ path('', BookListView.as_view(), name="books_list"), path('detail/<int:pk>', BookDetailView.as_view(), name="book_detail"), path('delete/<int:pk>', BookDeleteView.as_view(), name="book_delete"), ]
1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.urls import path from books.views import ( BookCreateView, BookDeleteView, BookListView, BookSearchResultsImportView, BookSearchView, BookUpdateView, IndexView, RESTBookListView, ) urlpatterns = [ path("", IndexView.as_view(), name="index"), path("api/books/", RESTBookListView.as_view(), name="rest_book_list"), path("books/", BookListView.as_view(), name="book_list"), path("books/add/", BookCreateView.as_view(), name="book_create"), path("books/<pk>/update/", BookUpdateView.as_view(), name="book_update"), path("books/<pk>/delete/", BookDeleteView.as_view(), name="book_delete"), path("books/search/", BookSearchView.as_view(), name="book_search"), path( "books/search-result/<isbn>/add/", BookSearchResultsImportView.as_view(), name="book_search_results_import", ), ]
"""main 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, register_converter from books.views import BookListView from books.converters import PubDateConverter register_converter(PubDateConverter, 'date_converter') urlpatterns = [ path('books/', BookListView.as_view(), name='books'), path('books/<date_converter:date>/', BookListView.as_view()), path('admin/', admin.site.urls), ]
def test_access_anonymous(self): req = RequestFactory().get(reverse('books:list')) req.user = AnonymousUser() resp = BookListView.as_view()(req) assert 'login' in resp.url, 'Should redirect to login page'
from django.urls import path from books.views import (AuthorCreateView, AuthorDeleteView, AuthorListView, AuthorUpdateView, BookCreateView, BookDeleteView, BookDetailView, BookListView, BookListViewDF, BookUpdateView, GenreCreateView, GenreDeleteView, GenreListView, GenreUpdateView) urlpatterns = [ path("bookstore/books/", BookListView.as_view(), name="bookstore"), path("bookstore/book/add-book", BookCreateView.as_view(), name="book-add"), path("bookstore/book/<int:pk>/", BookDetailView.as_view(), name="book-details"), path("bookstore/book/<int:pk>/update/", BookUpdateView.as_view(), name="book-update"), path("bookstore/book/<int:pk>/delete/", BookDeleteView.as_view(), name="book-delete"), path("bookstore/author/create/", AuthorCreateView.as_view(), name="author-add"), path("bookstore/authors/", AuthorListView.as_view(), name="authors"), path( "bookstore/author/<int:pk>/update", AuthorUpdateView.as_view(), name="author-update", ), path( "bookstore/author/<int:pk>/delete",
"""main 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, register_converter from books.views import BookListView from books.converters import PubDateConverter register_converter(PubDateConverter, 'date_converter') urlpatterns = [ path('admin/', admin.site.urls), path('books/', BookListView.as_view()), path('books/<date_converter:pub_date>/', BookListView.as_view()), ]
from django.urls import path from books.views import BookCreateView, BookListView, BookUpdateView, delete_book from categories.views import CategoriesListView, CategoryCreateView, CategoryUpdateView, category_delete urlpatterns = [ path('categories/', CategoriesListView.as_view()), path('categories/create/', CategoryCreateView.as_view()), path('categories/update/<int:pk>/', CategoryUpdateView.as_view()), path('categories/delete/<int:pk>/', category_delete), path('create/', BookCreateView.as_view()), path('update/<int:pk>/', BookUpdateView.as_view()), path('delete/<int:pk>/', delete_book), path('', BookListView.as_view()), ]
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, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from books.views import BookListView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^books/', include('books.urls', namespace='books')), url(r'^$', BookListView.as_view(), name='home_page'), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
"""main 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, re_path from books.views import BookListView urlpatterns = [ re_path(r'^books/(?P<pub_date>[0-9]{4}-[0-9]{2}-[0-9]{2})?/?$', BookListView.as_view(), name='books'), path('admin/', admin.site.urls), ]
from django.urls import path from books.views import BookListView urlpatterns = [ path("", BookListView.as_view(), name="home"), ]
from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include from drf_yasg import openapi from drf_yasg.views import get_schema_view from rest_framework.routers import DefaultRouter from books.views import GenresListView, FormatListView, ReviewCreateView, BookListView, api_root, BookViewSet router = DefaultRouter() router.register('books', BookViewSet) schema_view = get_schema_view(openapi.Info( title='Shop API', default_version='v1', description='My online shop\'s API'), public=True) urlpatterns = [ path('admin/', admin.site.urls), path('api/v1/', include('accounts.urls')), path('api/v1/', include(router.urls)), path('api/v1/docs/', schema_view.with_ui()), path('', api_root), path('api/v1/genres/', GenresListView.as_view(), name='genres-list'), path('api/v1/formats/', FormatListView.as_view(), name='formats-list'), path('api/v1/reviews/', ReviewCreateView.as_view(), name='create-review'), path('api/v1/books/', BookListView.as_view(), name='book-list'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)