def test_home_page(self): request = self.factory.get('/') response = HomePageView.as_view()(request) self.assertEqual(response.get('content-type'), 'text/html; charset=utf-8') self.assertEqual(response.status_code, 200) self.assertContains(response, 'Congratulations') """ Creates a simple sine wave plot """ fig = Figure() a = fig.add_subplot(111) t = np.arange(0.0, 3.0, 0.01) s = np.sin(2*np.pi*t) a.plot(t, s) fig.savefig('app/static/app/img/plot.svg')
"""project 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 from app.views import HomePageView, ListaPizzas urlpatterns = [ path('', HomePageView.as_view(), name='home'), path('admin/', admin.site.urls), path('list/', ListaPizzas.as_view(), name='lista_pizzas'), ]
router = routers.SimpleRouter() router.register('courses', CourseViewSet) router.register('records', RecordViewSet) router.register('bundles', BundleViewSet) urlpatterns = [ path('admin/', admin.site.urls), path('sentry-debug/', lambda request: 1 / 0), path('api/v2/users/<int:pk>/', UserView.as_view()), path('api/v2/banking/tinkoff-notifications/', TinkoffPaymentNotificationsView.as_view()), path('api/v2/leads/email/<slug:slug>/', EmailLeadMagnetCampaignView.as_view()), path('api/v2/healthchecks/', include('django_healthchecks.urls')), path('api/v2/', include(router.urls)), path('', HomePageView.as_view()), ] if settings.DEBUG: import debug_toolbar urlpatterns += [ path('__debug__/', include(debug_toolbar.urls)), ] if not settings.DEBUG and not settings.CI: """Redirect users from the errors to the frontend""" def redir_to_the_frontend(error_code): return lambda request, *args, **kwargs: redirect( urljoin(settings.FRONTEND_URL, f'/error/?code={error_code}')) handler400 = redir_to_the_frontend(400)
from django.urls import path from app.views import ( DefaultFormByFieldView, DefaultFormsetView, DefaultFormView, FormHorizontalView, FormInlineView, FormWithFilesView, HomePageView, MiscView, PaginationView, ) urlpatterns = [ path("", HomePageView.as_view(), name="home"), path("formset", DefaultFormsetView.as_view(), name="formset_default"), path("form", DefaultFormView.as_view(), name="form_default"), path("form_by_field", DefaultFormByFieldView.as_view(), name="form_by_field"), path("form_horizontal", FormHorizontalView.as_view(), name="form_horizontal"), path("form_inline", FormInlineView.as_view(), name="form_inline"), path("form_with_files", FormWithFilesView.as_view(), name="form_with_files"), path("pagination", PaginationView.as_view(), name="pagination"), path("misc", MiscView.as_view(), name="misc"), ]
from django.conf.urls import url from app.views import ( DefaultFormByFieldView, DefaultFormsetView, DefaultFormView, FormHorizontalView, FormInlineView, FormWithFilesView, HomePageView, MiscView, PaginationView, ) urlpatterns = [ url(r"^$", HomePageView.as_view(), name="home"), url(r"^formset$", DefaultFormsetView.as_view(), name="formset_default"), url(r"^form$", DefaultFormView.as_view(), name="form_default"), url(r"^form_by_field$", DefaultFormByFieldView.as_view(), name="form_by_field"), url(r"^form_horizontal$", FormHorizontalView.as_view(), name="form_horizontal"), url(r"^form_inline$", FormInlineView.as_view(), name="form_inline"), url(r"^form_with_files$", FormWithFilesView.as_view(), name="form_with_files"), url(r"^pagination$", PaginationView.as_view(), name="pagination"), url(r"^misc$", MiscView.as_view(), name="misc"), ]
from django.conf.urls import url from django.shortcuts import redirect from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.views import login, logout from app.views import send_morsel, start_hunt, MorselList, MorselDetailView,\ register, create_morsel, HomePageView, FAQPageView, AboutPageView,\ newsletter_signup, edit_morsel, morsel_list_public app_name = 'app' urlpatterns = [ url(r'^$', HomePageView.as_view(), name='home'), url(r'^morsels/$', MorselList.as_view(), name='morsel_list'), url(r'^morsels_public/$', morsel_list_public, name='morsel_list_public'), url(r'^morsels/send/$', send_morsel, name='morsel_send'), url(r'^morsels/(?P<morsel_id>[0-9]+)/start_hunt/$', start_hunt, name='start_hunt'), url(r'^register/', register, name='register'), url(r'^faq/$', FAQPageView.as_view(), name='faq'), url(r'^about/$', AboutPageView.as_view(), name='about'), url(r'^morsels/create/$', create_morsel, name="create_morsel"), url(r'^morsels/(?P<morsel_id>[0-9]+)/edit/$', edit_morsel, name='edit_morsel'), url(r'^morsels/(?P<pk>[0-9]+)/display/$', MorselDetailView.as_view(), name='morsel_detail'), url(r'^newsletter_signup/$', newsletter_signup, name='newsletter_signup') ]
from django.conf.urls import patterns, include, url from app.views import HomePageView # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', # Examples: url(r'^$', HomePageView.as_view(), name='home'), # url(r'^chartshow/', include('chartshow.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: # url(r'^admin/', include(admin.site.urls)), ) from django.conf import settings from django.conf.urls.static import static urlpatterns += patterns('', (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )
"""project URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.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 from django.conf.urls import url from app.views import HomePageView, contact, signup urlpatterns = [ url(r'webapp/^$', HomePageView.as_view(), name='home'), path('webapp/admin/', admin.site.urls), url(r'webapp/contact/$', contact, name='contact'), url(r'webapp/signup/$', signup, name='signup'), ]
from django.conf.urls import patterns, include, url from django.contrib import admin from django.http import HttpResponse from django.contrib.staticfiles.urls import staticfiles_urlpatterns from lionheart.utils import simple_url from lionheart.utils import template_url from lionheart.utils import home_url from lionheart.utils import status_204 from app.views import HomePageView admin.autodiscover() urlpatterns = patterns( 'app.views', url(r'^admin/', include(admin.site.urls)), url(r'^204$', status_204), home_url('home'), url(r'^homepage/', HomePageView.as_view(), name='homepage')) from django.conf import settings # nopep8 from django.conf.urls import include # nopep8 if settings.DEBUG: import debug_toolbar urlpatterns += patterns( '', url(r'^__debug__/', include(debug_toolbar.urls)), ) urlpatterns += staticfiles_urlpatterns()