我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用django.views.generic.RedirectView.as_view()。
def get_urls(self): from django.conf.urls import url def wrap(view): def wrapper(*args, **kwargs): return self.admin_site.admin_view(view)(*args, **kwargs) wrapper.model_admin = self return update_wrapper(wrapper, view) info = self.model._meta.app_label, self.model._meta.model_name urlpatterns = [ url(r'^$', wrap(self.changelist_view), name='%s_%s_changelist' % info), url(r'^add/$', wrap(self.add_view), name='%s_%s_add' % info), url(r'^(.+)/history/$', wrap(self.history_view), name='%s_%s_history' % info), url(r'^(.+)/delete/$', wrap(self.delete_view), name='%s_%s_delete' % info), url(r'^(.+)/change/$', wrap(self.change_view), name='%s_%s_change' % info), # For backwards compatibility (was the change url before 1.9) url(r'^(.+)/$', wrap(RedirectView.as_view( pattern_name='%s:%s_%s_change' % ((self.admin_site.name,) + info) ))), ] return urlpatterns
def get_urls(self): info = Broadcast._meta.app_label, Broadcast._meta.model_name urlpatterns = [ url(r'^broadcast', BroadcastView.as_view(), name='broadcast'), url(r'^$', RedirectView.as_view(pattern_name='admin:broadcast'), name='%s_%s_changelist' % info), ] return urlpatterns
def krb5login(request, redirect_field_name=REDIRECT_FIELD_NAME): #middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware' middleware = 'kobo.django.auth.middleware.LimitedRemoteUserMiddleware' if middleware not in settings.MIDDLEWARE_CLASSES: raise ImproperlyConfigured("krb5login view requires '%s' middleware installed" % middleware) redirect_to = request.REQUEST.get(redirect_field_name, "") if not redirect_to: redirect_to = reverse("home/index") return RedirectView.as_view(url=redirect_to)(request)
def gen_urls(): include_patterns = patterns("", url(r"^$", TemplateView.as_view(template_name="homepage.html"), name="home"), url(r"^admin/", include(admin.site.urls)), url(r"^account/signup/$", pycon.profile.views.SignupView.as_view(), name="account_signup"), url(r"^account/login/$", symposion.views.LoginView.as_view(), name="account_login"), url(r"^account/social/", include("social_auth.urls")), url(r"^account/associations/", include("symposion.social_auth.urls")), url(r"^account/", include("account.urls")), url(r"^dashboard/", symposion.views.dashboard, name="dashboard"), url(r"^blog/", include("biblion.urls")), url(r"^force500/", lambda request: xxx), url(r"^registration/", include("pycon.registration.urls")), url(r"^finaid/", include("pycon.finaid.urls")), url(r"^pycon_api/", include("pycon.pycon_api.urls")), url(r"^api/", include("pycon.apis.urls")), url(r"^schedule/", include("pycon.schedule.urls")), url(r"^profile/", include("pycon.profile.urls")), url(r"^tutorials/", include("pycon.tutorials.urls")), url(r"^speaker/", include("symposion.speakers.urls")), url(r"^speaker/list$", speaker_views.speaker_list, name='speaker_list'), url(r"^proposals/", include("pycon.proposals.urls")), url(r"^reviews/", include("symposion.reviews.urls")), url(r"^teams/", include("symposion.teams.urls")), url(r"^schedule/", include("symposion.schedule.urls")), url(r"^conference/", include("symposion.conference.urls")), url(r"^sponsors/", include("pycon.sponsorship.urls")), url(r"^boxes/", include("symposion.boxes.urls")), url(r"^sitemap/", TemplateView.as_view(template_name="static/sitemap.html"), name="sitemap"), url(r'^selectable/', include('selectable.urls')), url(r"^change_language/", symposion.views.change_language, name="change_language"), url(r"^", include("pycon.urls")), # This should be last, because it will create a new CMS page for # any unrecognized URL. url(r"^", include("restcms.urls")), url(r'^localeurl/', include('localeurlcustom.urls')), ) for key, val in settings.LANGUAGES: yield url(r"^%s/%s/" % (URL_PREFIX, key), include(include_patterns))