當前位置: 首頁>>代碼示例>>Python>>正文


Python JavaScriptCatalog.as_view方法代碼示例

本文整理匯總了Python中django.views.i18n.JavaScriptCatalog.as_view方法的典型用法代碼示例。如果您正苦於以下問題:Python JavaScriptCatalog.as_view方法的具體用法?Python JavaScriptCatalog.as_view怎麽用?Python JavaScriptCatalog.as_view使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.views.i18n.JavaScriptCatalog的用法示例。


在下文中一共展示了JavaScriptCatalog.as_view方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: password_change

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def password_change(self, request, extra_context=None):
        """
        Handle the "change password" task -- both form display and validation.
        """
        from django.contrib.admin.forms import AdminPasswordChangeForm
        from django.contrib.auth.views import PasswordChangeView
        url = reverse('admin:password_change_done', current_app=self.name)
        defaults = {
            'form_class': AdminPasswordChangeForm,
            'success_url': url,
            'extra_context': dict(self.each_context(request), **(extra_context or {})),
        }
        if self.password_change_template is not None:
            defaults['template_name'] = self.password_change_template
        request.current_app = self.name
        return PasswordChangeView.as_view(**defaults)(request) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:18,代碼來源:sites.py

示例2: logout

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def logout(self, request, extra_context=None):
        """
        Log out the user for the given HttpRequest.

        This should *not* assume the user is already logged in.
        """
        from django.contrib.auth.views import LogoutView
        defaults = {
            'extra_context': dict(
                self.each_context(request),
                # Since the user isn't logged out at this point, the value of
                # has_permission must be overridden.
                has_permission=False,
                **(extra_context or {})
            ),
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template
        request.current_app = self.name
        return LogoutView.as_view(**defaults)(request) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:22,代碼來源:sites.py

示例3: password_change

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def password_change(self, request, extra_context=None):
        """
        Handle the "change password" task -- both form display and validation.
        """
        from django.contrib.admin.forms import AdminPasswordChangeForm
        from django.contrib.auth.views import PasswordChangeView
        url = reverse('admin:password_change_done', current_app=self.name)
        defaults = {
            'form_class': AdminPasswordChangeForm,
            'success_url': url,
            'extra_context': {**self.each_context(request), **(extra_context or {})},
        }
        if self.password_change_template is not None:
            defaults['template_name'] = self.password_change_template
        request.current_app = self.name
        return PasswordChangeView.as_view(**defaults)(request) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:18,代碼來源:sites.py

示例4: logout

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def logout(self, request, extra_context=None):
        """
        Log out the user for the given HttpRequest.

        This should *not* assume the user is already logged in.
        """
        from django.contrib.auth.views import LogoutView
        defaults = {
            'extra_context': {
                **self.each_context(request),
                # Since the user isn't logged out at this point, the value of
                # has_permission must be overridden.
                'has_permission': False,
                **(extra_context or {})
            },
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template
        request.current_app = self.name
        return LogoutView.as_view(**defaults)(request) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:22,代碼來源:sites.py

示例5: password_change

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def password_change(self, request, extra_context=None):
        """
        Handles the "change password" task -- both form display and validation.
        """
        from django.contrib.admin.forms import AdminPasswordChangeForm
        from django.contrib.auth.views import PasswordChangeView
        url = reverse('admin:password_change_done', current_app=self.name)
        defaults = {
            'form_class': AdminPasswordChangeForm,
            'success_url': url,
            'extra_context': dict(self.each_context(request), **(extra_context or {})),
        }
        if self.password_change_template is not None:
            defaults['template_name'] = self.password_change_template
        request.current_app = self.name
        return PasswordChangeView.as_view(**defaults)(request) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:18,代碼來源:sites.py

示例6: logout

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def logout(self, request, extra_context=None):
        """
        Logs out the user for the given HttpRequest.

        This should *not* assume the user is already logged in.
        """
        from django.contrib.auth.views import LogoutView
        defaults = {
            'extra_context': dict(
                self.each_context(request),
                # Since the user isn't logged out at this point, the value of
                # has_permission must be overridden.
                has_permission=False,
                **(extra_context or {})
            ),
        }
        if self.logout_template is not None:
            defaults['template_name'] = self.logout_template
        request.current_app = self.name
        return LogoutView.as_view(**defaults)(request) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:22,代碼來源:sites.py

示例7: password_change_done

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def password_change_done(self, request, extra_context=None):
        """
        Display the "success" page after a password change.
        """
        from django.contrib.auth.views import PasswordChangeDoneView
        defaults = {
            'extra_context': dict(self.each_context(request), **(extra_context or {})),
        }
        if self.password_change_done_template is not None:
            defaults['template_name'] = self.password_change_done_template
        request.current_app = self.name
        return PasswordChangeDoneView.as_view(**defaults)(request) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:14,代碼來源:sites.py

示例8: i18n_javascript

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def i18n_javascript(self, request, extra_context=None):
        """
        Display the i18n JavaScript that the Django admin requires.

        `extra_context` is unused but present for consistency with the other
        admin views.
        """
        return JavaScriptCatalog.as_view(packages=['django.contrib.admin'])(request) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:10,代碼來源:sites.py

示例9: login

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def login(self, request, extra_context=None):
        """
        Display the login form for the given HttpRequest.
        """
        if request.method == 'GET' and self.has_permission(request):
            # Already logged-in, redirect to admin index
            index_path = reverse('admin:index', current_app=self.name)
            return HttpResponseRedirect(index_path)

        from django.contrib.auth.views import LoginView
        # Since this module gets imported in the application's root package,
        # it cannot import models from other applications at the module level,
        # and django.contrib.admin.forms eventually imports User.
        from django.contrib.admin.forms import AdminAuthenticationForm
        context = dict(
            self.each_context(request),
            title=_('Log in'),
            app_path=request.get_full_path(),
            username=request.user.get_username(),
        )
        if (REDIRECT_FIELD_NAME not in request.GET and
                REDIRECT_FIELD_NAME not in request.POST):
            context[REDIRECT_FIELD_NAME] = reverse('admin:index', current_app=self.name)
        context.update(extra_context or {})

        defaults = {
            'extra_context': context,
            'authentication_form': self.login_form or AdminAuthenticationForm,
            'template_name': self.login_template or 'admin/login.html',
        }
        request.current_app = self.name
        return LoginView.as_view(**defaults)(request) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:34,代碼來源:sites.py

示例10: create_admin_view

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def create_admin_view(self, admin_view_class):
        return self.get_view_class(admin_view_class).as_view() 
開發者ID:Superbsco,項目名稱:weibo-analysis-system,代碼行數:4,代碼來源:sites.py

示例11: create_model_admin_view

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def create_model_admin_view(self, admin_view_class, model, option_class):
        return self.get_view_class(admin_view_class, option_class).as_view() 
開發者ID:Superbsco,項目名稱:weibo-analysis-system,代碼行數:4,代碼來源:sites.py

示例12: i18n_javascript

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def i18n_javascript(self, request):
        from django.views.i18n import JavaScriptCatalog
        """
        Displays the i18n JavaScript that the Django admin requires.

        This takes into account the USE_I18N setting. If it's set to False, the
        generated JavaScript will be leaner and faster.
        """
        return JavaScriptCatalog.as_view(packages=['django.contrib.admin'])(request)

# This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site. 
開發者ID:Superbsco,項目名稱:weibo-analysis-system,代碼行數:14,代碼來源:sites.py

示例13: password_change_done

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def password_change_done(self, request, extra_context=None):
        """
        Display the "success" page after a password change.
        """
        from django.contrib.auth.views import PasswordChangeDoneView
        defaults = {
            'extra_context': {**self.each_context(request), **(extra_context or {})},
        }
        if self.password_change_done_template is not None:
            defaults['template_name'] = self.password_change_done_template
        request.current_app = self.name
        return PasswordChangeDoneView.as_view(**defaults)(request) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:14,代碼來源:sites.py

示例14: login

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def login(self, request, extra_context=None):
        """
        Display the login form for the given HttpRequest.
        """
        if request.method == 'GET' and self.has_permission(request):
            # Already logged-in, redirect to admin index
            index_path = reverse('admin:index', current_app=self.name)
            return HttpResponseRedirect(index_path)

        from django.contrib.auth.views import LoginView
        # Since this module gets imported in the application's root package,
        # it cannot import models from other applications at the module level,
        # and django.contrib.admin.forms eventually imports User.
        from django.contrib.admin.forms import AdminAuthenticationForm
        context = {
            **self.each_context(request),
            'title': _('Log in'),
            'app_path': request.get_full_path(),
            'username': request.user.get_username(),
        }
        if (REDIRECT_FIELD_NAME not in request.GET and
                REDIRECT_FIELD_NAME not in request.POST):
            context[REDIRECT_FIELD_NAME] = reverse('admin:index', current_app=self.name)
        context.update(extra_context or {})

        defaults = {
            'extra_context': context,
            'authentication_form': self.login_form or AdminAuthenticationForm,
            'template_name': self.login_template or 'admin/login.html',
        }
        request.current_app = self.name
        return LoginView.as_view(**defaults)(request) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:34,代碼來源:sites.py

示例15: password_change_done

# 需要導入模塊: from django.views.i18n import JavaScriptCatalog [as 別名]
# 或者: from django.views.i18n.JavaScriptCatalog import as_view [as 別名]
def password_change_done(self, request, extra_context=None):
        """
        Displays the "success" page after a password change.
        """
        from django.contrib.auth.views import PasswordChangeDoneView
        defaults = {
            'extra_context': dict(self.each_context(request), **(extra_context or {})),
        }
        if self.password_change_done_template is not None:
            defaults['template_name'] = self.password_change_done_template
        request.current_app = self.name
        return PasswordChangeDoneView.as_view(**defaults)(request) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:14,代碼來源:sites.py


注:本文中的django.views.i18n.JavaScriptCatalog.as_view方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。